-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0080cb7
commit 9bee280
Showing
26 changed files
with
137 additions
and
31 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
class ListNode { | ||
constructor(public val: number, public next: ListNode | null = null) { | ||
this.val = val; | ||
this.next = next; | ||
} | ||
} | ||
|
||
/** | ||
* @description 链表队列 | ||
*/ | ||
class LinkedListQueue { | ||
private front : ListNode | null; // 头节点 #front | ||
private rear : ListNode | null; // 尾节点 #rear | ||
private qsize: number = 0; | ||
constructor() { | ||
this.front = null; | ||
this.rear = null; | ||
} | ||
|
||
/* 获取队列的长度 */ | ||
get size(): number { | ||
return this.qsize; | ||
} | ||
|
||
/* 判断队列是否为空 */ | ||
isEmpty(): boolean { | ||
return this.size === 0; | ||
} | ||
|
||
push(num: number): void { | ||
const node = new ListNode(num); | ||
// 如果队列为空,则令头、尾节点都指向该节点 | ||
if (this.isEmpty()) { | ||
this.front = node; | ||
this.rear = node; | ||
} else { | ||
// 如果队列不为空,则将该节点添加到尾节点之后 | ||
this.rear.next = node; | ||
this.rear = node; | ||
} | ||
this.qsize++; | ||
} | ||
|
||
pop(): number | null { | ||
const num = this.peek(); | ||
if (this.isEmpty()) throw new Error('队列为空'); | ||
// 删除头节点 | ||
this.front = this.front.next; | ||
this.qsize--; | ||
return num; | ||
} | ||
|
||
/* 访问队首元素 */ | ||
peek(): number { | ||
if (this.isEmpty()) throw new Error('队列为空'); | ||
return this.front.val; | ||
} | ||
|
||
} | ||
|
||
|
||
/** | ||
* @description 双向队列 | ||
*/ | ||
class DoubleEndedQueue { | ||
constructor() { | ||
this.items = []; | ||
} | ||
} | ||
|
||
export { | ||
LinkedListQueue, | ||
DoubleEndedQueue | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# nodejs 相关utils (需要依赖平台api) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# 平台无关的 js utils |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# js web相关utils (需要依赖平台api) |
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import * as s from 'superstruct' | ||
|
||
const Email = s.define('Email', (string)=>{ | ||
|
||
}) | ||
|
||
|
||
export { | ||
s | ||
} |
This file was deleted.
Oops, something went wrong.