Skip to content

Commit

Permalink
Fix function names
Browse files Browse the repository at this point in the history
  • Loading branch information
chen3feng committed Aug 7, 2022
1 parent 0371018 commit dab8db5
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 38 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Package stl4go is a generic container and algorithm library for go.
- [func UpperBound[T Ordered](a []T, value T) int](<#func-upperbound>)
- [func UpperBoundFunc[T any](a []T, value T, less LessFn[T]) int](<#func-upperboundfunc>)
- [type BuiltinSet](<#type-builtinset>)
- [func MakeSetOf[K comparable](ks ...K) BuiltinSet[K]](<#func-makesetof>)
- [func MakeBuiltinSetOf[K comparable](ks ...K) BuiltinSet[K]](<#func-makebuiltinsetof>)
- [func (s *BuiltinSet[K]) Clear()](<#func-builtinsetk-clear>)
- [func (s *BuiltinSet[K]) ForEach(cb func(k K))](<#func-builtinsetk-foreach>)
- [func (s *BuiltinSet[K]) ForEachIf(cb func(k K) bool)](<#func-builtinsetk-foreachif>)
Expand Down Expand Up @@ -696,13 +696,13 @@ BuiltinSet is an associative container that contains a unordered set of unique o
type BuiltinSet[K comparable] map[K]bool
```

### func [MakeSetOf](<https://github.com/chen3feng/stl4go/blob/master/builtin_set.go#L11>)
### func [MakeBuiltinSetOf](<https://github.com/chen3feng/stl4go/blob/master/builtin_set.go#L11>)

```go
func MakeSetOf[K comparable](ks ...K) BuiltinSet[K]
func MakeBuiltinSetOf[K comparable](ks ...K) BuiltinSet[K]
```

MakeSetOf creates a new BuiltinSet object with the initial content from ks.
MakeBuiltinSetOf creates a new BuiltinSet object with the initial content from ks.

### func \(\*BuiltinSet\[K\]\) [Clear](<https://github.com/chen3feng/stl4go/blob/master/builtin_set.go#L25>)

Expand Down
8 changes: 4 additions & 4 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Package stl4go is a generic container and algorithm library for go.
- [func UpperBound[T Ordered](a []T, value T) int](<#func-upperbound>)
- [func UpperBoundFunc[T any](a []T, value T, less LessFn[T]) int](<#func-upperboundfunc>)
- [type BuiltinSet](<#type-builtinset>)
- [func MakeSetOf[K comparable](ks ...K) BuiltinSet[K]](<#func-makesetof>)
- [func MakeBuiltinSetOf[K comparable](ks ...K) BuiltinSet[K]](<#func-makebuiltinsetof>)
- [func (s *BuiltinSet[K]) Clear()](<#func-builtinsetk-clear>)
- [func (s *BuiltinSet[K]) ForEach(cb func(k K))](<#func-builtinsetk-foreach>)
- [func (s *BuiltinSet[K]) ForEachIf(cb func(k K) bool)](<#func-builtinsetk-foreachif>)
Expand Down Expand Up @@ -692,13 +692,13 @@ BuiltinSet is an associative container that contains a unordered set of unique o
type BuiltinSet[K comparable] map[K]bool
```

### func [MakeSetOf](<https://github.com/chen3feng/stl4go/blob/master/builtin_set.go#L11>)
### func [MakeBuiltinSetOf](<https://github.com/chen3feng/stl4go/blob/master/builtin_set.go#L11>)

```go
func MakeSetOf[K comparable](ks ...K) BuiltinSet[K]
func MakeBuiltinSetOf[K comparable](ks ...K) BuiltinSet[K]
```

MakeSetOf creates a new BuiltinSet object with the initial content from ks.
MakeBuiltinSetOf creates a new BuiltinSet object with the initial content from ks.

### func \(\*BuiltinSet\[K\]\) [Clear](<https://github.com/chen3feng/stl4go/blob/master/builtin_set.go#L25>)

Expand Down
4 changes: 2 additions & 2 deletions builtin_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
// BuiltinSet is an associative container that contains a unordered set of unique objects of type K.
type BuiltinSet[K comparable] map[K]bool

// MakeSetOf creates a new BuiltinSet object with the initial content from ks.
func MakeSetOf[K comparable](ks ...K) BuiltinSet[K] {
// MakeBuiltinSetOf creates a new BuiltinSet object with the initial content from ks.
func MakeBuiltinSetOf[K comparable](ks ...K) BuiltinSet[K] {
s := make(BuiltinSet[K])
s.InsertN(ks...)
return s
Expand Down
56 changes: 28 additions & 28 deletions builtin_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,61 +6,61 @@ import (
"testing"
)

func Test_Set_Interface(t *testing.T) {
func Test_BuiltinSet_Interface(t *testing.T) {
s := make(BuiltinSet[int])
_ = Set[int](&s)
}

func Test_MakeSet(t *testing.T) {
func Test_MakeBuiltinSet(t *testing.T) {
s := make(BuiltinSet[string])
expectEq(t, s.Len(), 0)
expectEq(t, s.IsEmpty(), true)
}

func Test_MakeSet2(t *testing.T) {
func Test_MakeBuiltinSet2(t *testing.T) {
s := BuiltinSet[string]{}
expectEq(t, s.Len(), 0)
expectEq(t, s.IsEmpty(), true)
}

func Test_MakeSetOf(t *testing.T) {
s := MakeSetOf("hello", "world")
func Test_MakeBuiltinSetOf(t *testing.T) {
s := MakeBuiltinSetOf("hello", "world")
expectEq(t, s.Len(), 2)
}

func Test_Set_IsEmpty(t *testing.T) {
func Test_BuiltinSet_IsEmpty(t *testing.T) {
s := make(BuiltinSet[string])
expectEq(t, s.IsEmpty(), true)
s.Insert("hello")
expectEq(t, s.IsEmpty(), false)
}

func Test_Set_Clear(t *testing.T) {
s := MakeSetOf("hello", "world")
func Test_BuiltinSet_Clear(t *testing.T) {
s := MakeBuiltinSetOf("hello", "world")
s.Clear()
expectTrue(t, s.IsEmpty())
}

func Test_Set_String(t *testing.T) {
s := MakeSetOf("hello", "world")
func Test_BuiltinSet_String(t *testing.T) {
s := MakeBuiltinSetOf("hello", "world")
expectTrue(t, strings.HasPrefix(fmt.Sprintf("%v", s), "BuiltinSet[string]"))
}

func Test_Set_Has(t *testing.T) {
s := MakeSetOf("hello", "world")
func Test_BuiltinSet_Has(t *testing.T) {
s := MakeBuiltinSetOf("hello", "world")
expectTrue(t, s.Has("hello"))
expectTrue(t, s.Has("world"))
expectFalse(t, s.Has("!"))
}

func Test_Set_Get(t *testing.T) {
s := MakeSetOf("hello", "world")
func Test_BuiltinSet_Get(t *testing.T) {
s := MakeBuiltinSetOf("hello", "world")
expectTrue(t, s["hello"])
expectTrue(t, s["world"])
expectFalse(t, s["!"])
}

func Test_Set_Insert(t *testing.T) {
func Test_BuiltinSet_Insert(t *testing.T) {
s := make(BuiltinSet[string])
s.Insert("hello")
s.Insert("hello")
Expand All @@ -70,14 +70,14 @@ func Test_Set_Insert(t *testing.T) {
expectEq(t, s.Len(), 2)
}

func Test_Set_InsertN(t *testing.T) {
func Test_BuiltinSet_InsertN(t *testing.T) {
s := make(BuiltinSet[string])
s.InsertN("hello", "world")
expectEq(t, s.Len(), 2)
}

func Test_Set_Remove(t *testing.T) {
s := MakeSetOf("hello", "world")
func Test_BuiltinSet_Remove(t *testing.T) {
s := MakeBuiltinSetOf("hello", "world")
s.Remove("hello")
expectEq(t, s.Len(), 1)
s.Remove("hello")
Expand All @@ -86,37 +86,37 @@ func Test_Set_Remove(t *testing.T) {
expectEq(t, s.Len(), 0)
}

func Test_Set_RemoveN(t *testing.T) {
s := MakeSetOf("hello", "world")
func Test_BuiltinSet_RemoveN(t *testing.T) {
s := MakeBuiltinSetOf("hello", "world")
s.RemoveN("hello", "world")
s.Remove("world")
expectTrue(t, s.IsEmpty())
}

func Test_Set_Keys(t *testing.T) {
s := MakeSetOf("hello", "world")
func Test_BuiltinSet_Keys(t *testing.T) {
s := MakeBuiltinSetOf("hello", "world")
ks := s.Keys()
expectEq(t, 2, len(ks))
}

func Test_Set_For(t *testing.T) {
s := MakeSetOf("hello", "world")
func Test_BuiltinSet_For(t *testing.T) {
s := MakeBuiltinSetOf("hello", "world")
for v := range s {
expectTrue(t, v == "hello" || v == "world")
}
}

func Test_Set_ForEach(t *testing.T) {
s := MakeSetOf("hello", "world")
func Test_BuiltinSet_ForEach(t *testing.T) {
s := MakeBuiltinSetOf("hello", "world")
c := 0
s.ForEach(func(string) {
c++
})
expectEq(t, c, 2)
}

func Test_Set_ForEachIf(t *testing.T) {
s := MakeSetOf("hello", "world")
func Test_BuiltinSet_ForEachIf(t *testing.T) {
s := MakeBuiltinSetOf("hello", "world")
c := 0
s.ForEachIf(func(string) bool {
c++
Expand Down

0 comments on commit dab8db5

Please sign in to comment.