FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
javascript-algorithms/src/data-structures/queue/Queue.js at master · hrmsandi/javascript-algorithms · GitHub
hrmsandi
/
javascript-algorithms
Public
forked from
trekhleb/javascript-algorithms
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
javascript-algorithms
/
src
/
data-structures
/
queue
/
Queue.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
32 lines (25 loc) · 571 Bytes
Breadcrumbs
javascript-algorithms
/
src
/
data-structures
/
queue
/
Queue.js
Copy path
File metadata and controls
32 lines (25 loc) · 571 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import
LinkedList
from
'../linked-list/LinkedList'
;
export
default
class
Queue
{
constructor
(
)
{
this
.
linkedList
=
new
LinkedList
(
)
;
}
isEmpty
(
)
{
return
!
this
.
linkedList
.
tail
;
}
peek
(
)
{
if
(
!
this
.
linkedList
.
head
)
{
return
null
;
}
return
this
.
linkedList
.
head
.
value
;
}
enqueue
(
value
)
{
this
.
linkedList
.
append
(
value
)
;
}
dequeue
(
)
{
const
removedHead
=
this
.
linkedList
.
deleteHead
(
)
;
return
removedHead
?
removedHead
.
value
:
null
;
}
toString
(
callback
)
{
return
this
.
linkedList
.
toString
(
callback
)
;
}
}
Back
|
FazBrowse Home
|
New Git URL