mirror of
https://github.com/emirpasic/gods.git
synced 2026-06-26 17:56:21 +03:00
- update documentation, closes #73
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
// Copyright (c) 2015, Emir Pasic. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/emirpasic/gods/lists/arraylist"
|
||||
"github.com/emirpasic/gods/utils"
|
||||
)
|
||||
|
||||
// ArrayListExample to demonstrate basic usage of ArrayList
|
||||
func main() {
|
||||
list := arraylist.New()
|
||||
list.Add("a") // ["a"]
|
||||
list.Add("c", "b") // ["a","c","b"]
|
||||
list.Sort(utils.StringComparator) // ["a","b","c"]
|
||||
_, _ = list.Get(0) // "a",true
|
||||
_, _ = list.Get(100) // nil,false
|
||||
_ = list.Contains("a", "b", "c") // true
|
||||
_ = list.Contains("a", "b", "c", "d") // false
|
||||
list.Swap(0, 1) // ["b","a",c"]
|
||||
list.Remove(2) // ["b","a"]
|
||||
list.Remove(1) // ["b"]
|
||||
list.Remove(0) // []
|
||||
list.Remove(0) // [] (ignored)
|
||||
_ = list.Empty() // true
|
||||
_ = list.Size() // 0
|
||||
list.Add("a") // ["a"]
|
||||
list.Clear() // []
|
||||
}
|
||||
Reference in New Issue
Block a user