mirror of https://github.com/emirpasic/gods
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
869 B
Go
24 lines
869 B
Go
// 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/sets/linkedhashset"
|
|
|
|
// LinkedHashSetExample to demonstrate basic usage of LinkedHashSet
|
|
func main() {
|
|
set := linkedhashset.New() // empty
|
|
set.Add(5) // 5
|
|
set.Add(4, 4, 3, 2, 1) // 5, 4, 3, 2, 1 (in insertion-order, duplicates ignored)
|
|
set.Remove(4) // 5, 3, 2, 1 (in insertion-order)
|
|
set.Remove(2, 3) // 5, 1 (in insertion-order)
|
|
set.Contains(1) // true
|
|
set.Contains(1, 5) // true
|
|
set.Contains(1, 6) // false
|
|
_ = set.Values() // []int{5, 1} (in insertion-order)
|
|
set.Clear() // empty
|
|
set.Empty() // true
|
|
set.Size() // 0
|
|
}
|