Skip to content

Commit 87d37a3

Browse files
committed
file rename
1 parent a76d364 commit 87d37a3

15 files changed

+25
-102
lines changed

stack_array.go renamed to array_stack.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package stack
22

3+
import "fmt"
4+
35
// ArrayStack 数组实现的栈
46
type ArrayStack[T any] struct {
57

@@ -76,6 +78,5 @@ func (x *ArrayStack[T]) Clear() error {
7678
}
7779

7880
func (x *ArrayStack[T]) String() string {
79-
//TODO implement me
80-
panic("implement me")
81+
return fmt.Sprintf("%#v", x)
8182
}
File renamed without changes.

errors.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,3 @@ package stack
33
import "errors"
44

55
var ErrStackEmpty = errors.New("stack empty")
6-
7-
var ErrContextTimeout = errors.New("timeout")

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module github.com/CC11001100/go-stack
22

3-
go 1.19
3+
go 1.18
File renamed without changes.
File renamed without changes.
File renamed without changes.

min_stack_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package stack
2+
3+
import "testing"
4+
5+
func TestMinStack(t *testing.T) {
6+
7+
8+
9+
}
10+

stack.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,31 @@ package stack
33
// Stack 定义栈的API
44
type Stack[T any] interface {
55

6-
// Push 往栈中加入元素
6+
// Push 往栈中加入元素,可以一次增加多个
77
Push(values ...T) error
88

9+
// Pop 弹出栈顶元素,如果栈为空的话返回栈元素T对应的零值
910
Pop() T
11+
// PopE 弹出栈顶元素,如果栈为空的话则返回 ErrStackEmpty 错误
1012
PopE() (T, error)
1113

14+
// Peek 访问但不弹出栈顶元素,如果栈为空的话则返回栈元素T对应的零值
1215
Peek() T
16+
// PeekE 访问但不弹出栈顶元素,如果栈为空的话则返回 ErrStackEmpty 错误
1317
PeekE() (T, error)
1418

19+
// IsEmpty 栈是否为空
1520
IsEmpty() bool
21+
// IsNotEmpty 栈是否不为空
1622
IsNotEmpty() bool
1723

24+
// Len 返回栈中元素的个数
1825
Len() int
1926

27+
// Clear 清空栈
2028
Clear() error
2129

30+
// String 把栈打印为字符串,一般debug之类的可能会用得到
2231
String() string
2332
}
2433

stack_blocking_impl.go

Lines changed: 0 additions & 96 deletions
This file was deleted.

0 commit comments

Comments
 (0)