stack

Clearing Activity Stack

半腔热情 提交于 2019-12-08 04:26:48
问题 I am having trouble clearing my app's activity stack. At the start of my app I make the user login and give them a session id. After they login they are able to continue on using the app. However if there session expires I want to redirect them to the login activity and clear the Activity history so they can't have access to the app. I looked at the Android API and the Intent flag FLAG_ACTIVITY_CLEAR_TASK seems to be want I want but it was just included in API level 11 and no phones have the

How do I dump my stack in Arduino?

对着背影说爱祢 提交于 2019-12-08 04:25:30
I'm looking for a way to dump the stack of my arduino. I know there is a stack pointer (SP) available, what I try at the moment is: char* stack = (char*)SP; int counter = 0; strncpy(c, &stack[counter], 1); while(counter < 200) { counter++; strncat(c, &stack[counter], 1); } Serial.print(c); I don't get anything like a stack so I don't know if I'm doing it right. Please help! uint8_t stackArray[30]; void createStackDump() { volatile uint8_t* mSP = (uint8_t*)SP; for (int i = 0; i < 30; i++) { stackArray[i] = *mSP; mSP++; } } Call addresses on the stack are LSB first, so LSB has the higher stack

While making a function call in C, is the stack of OS used, and is the size of stack fixed?

冷暖自知 提交于 2019-12-08 03:56:23
问题 Here's my code #include<stdio.h> #define ROW 10000 #define COLUMN 10000 void hello(int arr[ROW][COLUMN]){ printf("hoho"); } void main(){ int arr[ROW][COLUMN]; hello(arr); } Now, this gives me segmentation fault. My question is, that I understand that while making a function call, stack is used to keep all the variables passed to the function. So is this the stack of OS? i.e. does OS has a separate memory block designed specially for this? Also, is the size of stack fixed? What if I have to

Add missing left parentheses into equation [closed]

冷暖自知 提交于 2019-12-08 01:34:36
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I'm pretty stuck in finding a proper solution for a given problem, been looking for some ideas over the internet. Wasn't be able to find any. Problem is: writing a program that takes from the standard input an expression without left parentheses and prints the equivalent infix expression with the parentheses

【算法系列 二】Stack

青春壹個敷衍的年華 提交于 2019-12-07 21:49:12
栈应用的场景: 1.括号问题 2.后缀表达式 3.深度优先遍历 4.保存现场 1. 给定字符串,仅由“()[]{}”六个字符组成。设计算法,判断该字符串是否有效。 括号必须以正确的顺序配对,如“()”、“()[]{}”是有效的,但 " ([)]"是无效的( Leetcode 20 )。 思想就是碰到左括号压栈,右括号出栈,然后判断弹出的元素是不是一对,最后栈为空则是真的。 代码如下: public class Solution { public boolean isValid(String s) { Stack<Character> stack = new Stack<Character>(); boolean isvalid = true; char[] c = s.toCharArray(); char temp; for (int i = 0; i < c.length; i++) { switch (c[i]) { case '(': stack.push(c[i]); break; case ')': if(stack.isEmpty()) { isvalid = false; }else { temp = stack.pop(); if (temp != '(') { isvalid = false; } } break; case '[': stack.push(c

iphone NavigationController clear views stack

柔情痞子 提交于 2019-12-07 18:38:18
问题 I have an iphone application that uses a navigation controller. In that controller I push some views. In some cases I want to "clear" the views stack, leave only the rootViewController of the navigation controller in the stack and push another viewController I have. Can someone give me an example on how to do this? I don't see any method that clears the stack. Answer 1: I have tried to put in button Action the following code: [self.navigationController popToRootViewControllerAnimated:NO]; do

How to implement a dequeue using two stacks

左心房为你撑大大i 提交于 2019-12-07 18:19:41
问题 Dequeue - Doubly ended queue: en-queue and de-queue possible from both ends. How to define ADT operations for dequeue using 2 stacks. Implementation should also take into consideration the performance. 回答1: the simplest solution would be to use one stack as the head of the queue, and one as the tail. The enqueue operations would just be a push to the respective stack, and the dequeue operations would just be a pop on the respective stack. However, if the stack you want to dequeue from is

how can i unstack without sorting in pandas?

不羁岁月 提交于 2019-12-07 18:10:20
问题 i have below time-series data couple of day.. and i wanna unstack by 'Date' it. but i used .unstack() then automatically sorted of time.. (Date/Time is multi index) Date Time a b c d e 2015-12-06 22:00:00 21.26 0 2.62 242.195 0 2015-12-06 22:15:00 21.14 0 2.55 255.516 0 2015-12-06 22:30:00 21.2 0 2.49 241.261 0 2015-12-06 22:45:00 21.18 0 2.48 232.058 0 2015-12-06 23:00:00 21.12 0 2.38 239.661 0 2015-12-06 23:15:00 21 0 2.23 228.324 0 2015-12-06 23:30:00 21.13 0 2.29 0 0 2015-12-06 23:45:00

Is this vulnerable to a stack overflow?

試著忘記壹切 提交于 2019-12-07 18:07:31
void gctinp (char *inp, int siz) { puts ("Input value: "); fgets (inp, siz, stdin); printf ("buffer3 getinp read %s", inp); } From what I've read, fgets is supposed to be used when you want to limit the size of input. So this code shouldn't be vulnerable right? It is being called like so: int main (int argc, char *argv[]) { char buf[16]; getinp (buf, sizeof (buf)); display (buf); printf ("buffer3 done\n"); } Thanks for your time. You won't strike buffer overflow problems if you enter more characters than can be safely stored since fgets restricts the input. It also adds a null terminator

Implement stack (push, pop and findmin) in O(1)

扶醉桌前 提交于 2019-12-07 17:38:46
问题 I have already seen two stack implementation of this question but I am really confused as how one could get O(1) operation. consider following example: S1[3542761986759] S2[3332221111111] The idea/algorithm here is Push element E on S1 Check to see if top of S2 >= E and if true, insert E on S2 But when getMin is called, we return top of S2 but that leaves S2 in weird state as S2 contains repeated current min elements, so the solution is to search next minimum element in S2 and return it. This