Documentation ¶
Index ¶
- type Strings
- func (s *Strings) Append(data ...string)
- func (s Strings) Cap() int
- func (s Strings) Copy() Strings
- func (s *Strings) Insert(index int, data ...string)
- func (s Strings) Join(sep string) string
- func (s Strings) Len() int
- func (s Strings) Less(i, j int) bool
- func (s *Strings) Prepend(data ...string)
- func (s *Strings) Remove(index, num int) int
- func (s Strings) ReverseSort() Strings
- func (s Strings) Shuffle() Strings
- func (s Strings) Sort() Strings
- func (s Strings) Swap(i, j int)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Strings ¶
type Strings []string
Strings 定义方便操作[]string的类型
Example ¶
package main import ( "fmt" "github.com/recallsong/go-utils/container/slice/strings" ) func main() { s := strings.Strings{} s.Append("abc", "abcd") s.Prepend("123", "456", "1234") s.Insert(1, "efg", "12") fmt.Println(s, s.Len()) s1 := s.Copy() removed := s1.Remove(1, 1) fmt.Println(s1, s1.Len(), removed) }
Output: [123 efg 12 456 1234 abc abcd] 7 [123 12 456 1234 abc abcd] 6 1
Example (Order) ¶
package main import ( "fmt" "github.com/recallsong/go-utils/container/slice/strings" ) func main() { s := strings.Strings{} s.Append("5", "4", "6", "3", "1", "2") s.Sort() fmt.Println(s) s.ReverseSort() fmt.Println(s) s.Shuffle() //随机打乱数据 // fmt.Println(s) }
Output: [1 2 3 4 5 6] [6 5 4 3 2 1]
func (Strings) ReverseSort ¶
Click to show internal directories.
Click to hide internal directories.