栈和队列:与列表类似但更复杂的数据结构。 链表:如何通过它们克服数组的不足。 字典:将数据以键-值对的形式存储。 散列:适用于快速查找和检索。 集合:适用于存储只出现一次的元素。 二叉树:以层级的形式存储数据。 图和图算法:网络建模的理想选择。 算法:包括排序或搜索数据的算法。 高级算法:动态规划和贪心算法。 名人推荐 “本书对前端工程师是非常好的数据结构与算法入门书籍,它的难度非常适合前端工程师来补习基础知识。”——程劭非,阿里无线事业部高级技术专家" />
了解数据结构与算法是透彻理解计算机科学的前提。随着Python日益广泛的应用,Python程序员需要实现与传统...
本书首先介绍了JavaScript语言的基础知识(包括ECMAScript和TypeScript),其次讨论了...
本书是数据结构与算法的入门指南,不局限于某种特定语言,略过复杂的数学公式,用通俗易懂的方式针对编程初学者介绍数...
本书首先介绍了JavaScript 语言的基础知识以及ES6 和ES7 中引入的新功能,接下来讨论了数组、栈、...
本书首先介绍了JavaScript语言的基础知识,接下来讨论了数组、栈、队列、链表、集合、字典、散列表、树、图...
https://byfat.xxx/if-hemingway-wrote-javascript 在写第一行代码很久以前,我就酷爱文学。现在,我写JavaScript,不计其数。我正在写一本关于JavaScript的书。 JavaScript凭啥能吸引那么多文艺青年?说到它…...
2.书中的JavaScript shell下载链接已经失效,最新链接在(https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central/,安装包位于目录的最下方
3.书中的代码错漏百出,原版如此,中文版也如此,一错再错,薄薄的一本书,质量把关居然这么不严,manbetx户口真该好好反思一下。
4.这本书只是对各算法的速览,讲的不够深入
5.我不会向任何人推荐本书
function List() {
this.listSize = 0;
this.pos = 0;
this.dataStore = [];
this.clear = clear;
this.find = find;
this.toString = toString;
this.insert = insert;
this.append = append;
this.remove = remove;
this.front = front;
this.end = end;
this.prev = prev;
this.next = next;
this.lenght = length;
this.currPos = currPos;
this.moveTo = moveTo;
this.getElement = getElement;
this.length = length;
this.contains = contains;
this.hasNext = hasNext;
this.hasPrev = hasPrev;
}
function append(element) {
this.dataStore[this.listSize++] = element;
}
function find(element) {
for (var i = 0; i < this.dataStore.length; ++i) {
if (this.dataStore[i] == element) {
return i;
}
}
return -1;
}
function remove(element) {
var foundAt = this.find(element);
if (foundAt > -1) {
this.dataStore.splice(foundAt, 1);
--this.listSize;
return true;
}
return false;
}
function length() {
return this.listSize;
}
function toString() {
return this.dataStore;
}
function insert(element, after) {
var insertPos = this.find(after);
if (insertPos > -1) {
this.dataStore.splice(insertPos+1, 0, element);
++this.listSize;
return true;
}
return false;
}
function clear() {
delete this.dataStore;
this.dataStore = [];
this.listSize = this.post = 0;
}
function contains(elemet) {
return (this.find(elemet) != -1);
}
function front() {
this.pos = 0;
}
function end() {
this.pos = this.listSize - 1;
}
function prev() {
//if (this.pos > 0) {
--this.pos;
//}
}
function next() {
//if (this.pos < this.listSize - 1) {
++this.pos;
//}
}
function currPos() {
return this.pos;
}
function hasNext() {
return this.pos < this.length();
}
function hasPrev() {
return this.pos-1 > 0;
}
function moveTo(position) {
this.pos = position;
}
function getElement() {
return this.dataStore[this.pos];
}
var names = new List();
names.append("Clayton");
names.append("Raymond");
names.append("Cynthia");
names.append("Jennifer");
names.append("Bryan");
names.append("Danny");
for(names.front(); names.hasNext(); names.next()) {
print(names.getElement());
}
for(names.end(); names.hasPrev(); names.prev()) {
print(names.getElement());
}
```
来看一个使用迭代器遍历列表的例子:
for(names.front(); names.currPos() < names.length(); names.next()) {
print(names.getElement());
}
```
将里面的代码换成下面这样,代码即可正常运行
```
for(names.front(); ;names.next()){
print(names.getElement())
if(names.currPos() == names.length()-1){
print('Done!')
return
}
}
```