您的位置:首页 > Web前端 > JavaScript

JavaScript队列或者堆栈的实现

2014-11-17 14:28 169 查看
Key Points :

array.splice(index, num);

// pop elements whose indices range from index to (index+num)from array.

then add element by push() method.

The rest concentration only needs to be focused on the end to be operated upon.

Tips :

Always keep in mind that the difference between stack and queue exists in the ends that are operated upon.

Stack : only one end is operated upon for both add and delete operation.

Queue : two ends are both operated upon, specifically to say, add in the start end and delete from the tail end.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: