FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
algorithms/data-structures/stack/stack.go at master · arnauddri/algorithms · GitHub
arnauddri
/
algorithms
Public
Notifications
You must be signed in to change notification settings
Fork
264
Star
1.8k
Code
Issues
10
Pull requests
10
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
algorithms
/
data-structures
/
stack
/
stack.go
Copy path
More file actions
More file actions
Latest commit
History
History
History
57 lines (43 loc) · 792 Bytes
Breadcrumbs
algorithms
/
data-structures
/
stack
/
stack.go
Copy path
File metadata and controls
57 lines (43 loc) · 792 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package
stack
import
"sync"
type
Stack
struct
{
stack
[]
interface
{}
len
int
lock
sync.
Mutex
}
func
New
()
*
Stack
{
s
:=
&
Stack
{}
s
.
stack
=
make
([]
interface
{},
0
)
s
.
len
=
0
return
s
}
func
(
s
*
Stack
)
Len
()
int
{
s
.
lock
.
Lock
()
defer
s
.
lock
.
Unlock
()
return
s
.
len
}
func
(
s
*
Stack
)
isEmpty
()
bool
{
s
.
lock
.
Lock
()
defer
s
.
lock
.
Unlock
()
return
s
.
len
==
0
}
func
(
s
*
Stack
)
Pop
() (
el
interface
{}) {
s
.
lock
.
Lock
()
defer
s
.
lock
.
Unlock
()
el
,
s
.
stack
=
s
.
stack
[
0
],
s
.
stack
[
1
:]
s
.
len
--
return
}
func
(
s
*
Stack
)
Push
(
el
interface
{}) {
s
.
lock
.
Lock
()
defer
s
.
lock
.
Unlock
()
prepend
:=
make
([]
interface
{},
1
)
prepend
[
0
]
=
el
s
.
stack
=
append
(
prepend
,
s
.
stack
...
)
s
.
len
++
}
func
(
s
*
Stack
)
Peek
()
interface
{} {
s
.
lock
.
Lock
()
defer
s
.
lock
.
Unlock
()
return
s
.
stack
[
0
]
}
Back
|
FazBrowse Home
|
New Git URL