小编mae*_*evy的帖子

Stack to - > ArrayList Java

我制作了一个Stack和一个ArrayList来进行研究.实际上我现在想要将我的Stack替换为ArrayList,但是如何将Stack转换为ArrayList?推,弹......怎么样?

谢谢

public static ArrayList<State> search(State finalstate)
{
    ArrayList<State> toreturn = new ArrayList<State>();
    Stack<State>mystack=new Stack<State>();
    mystack.push(initState);
    State currState;
    currState=initState;
    while(!mystack.isEmpty() && !currState.equals(finalstate) )
    {
        currState=mystack.pop();
        toreturn.add(currState);
        if(currState.vecinos.containsKey("up"))
        {
            mystack.push(currState).vecinos.get("up");
        }
        if(currState.vecinos.containsKey("down"))
        {
            mystack.push(currState).vecinos.get("down");
        }
        if(currState.vecinos.containsKey("left"))
        {
            mystack.push(currState).vecinos.get("left");
        }
        if(currState.vecinos.containsKey("right"))
        {
            mystack.push(currState).vecinos.get("right");
        }
    }

    return toreturn;
}
Run Code Online (Sandbox Code Playgroud)

java stack arraylist

11
推荐指数
2
解决办法
1万
查看次数

如何将所选UIActionSheet按钮的标题添加到标签中?

我有一个带有一些选项的按钮.

- (IBAction)monstrarActionSheet:(id)sender {
    UIActionSheet *action = [[UIActionSheet alloc] initWithTitle:@"Titulo"
                                                        delegate:self
                                               cancelButtonTitle:@"Mejor no" destructiveButtonTitle:@"Que miedo" otherButtonTitles:@"Otro boton 1", @"Otro boton 2", nil];
    [action showInView: self.view];
Run Code Online (Sandbox Code Playgroud)

选择某个选项后,我会在日志中显示一条消息,以显示选择了哪个按钮.

-(void) actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
    /*if(actionSheet.tag == 1){

    }*/

    NSLog(@"El usuario seleciono el boton %ld", (long)buttonIndex);
}
Run Code Online (Sandbox Code Playgroud)

在我的ViewController.h我的按钮和标签是这样定义的

@interface ViewController : UIViewController <UIActionSheetDelegate>

@property (weak, nonatomic) IBOutlet UILabel *lbViewController1;
Run Code Online (Sandbox Code Playgroud)

如何将所选UIActionSheet按钮的标题放入我的lbViewController1标签中?

objective-c uiactionsheet ios

6
推荐指数
1
解决办法
6226
查看次数

标签 统计

arraylist ×1

ios ×1

java ×1

objective-c ×1

stack ×1

uiactionsheet ×1