gitee.com/quant1x/gox@v1.21.2/util/examples/linkedhashset/linkedhashset.go (about)

     1  // Copyright (c) 2015, Emir Pasic. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package main
     6  
     7  import "gitee.com/quant1x/gox/util/linkedhashset"
     8  
     9  // LinkedHashSetExample to demonstrate basic usage of LinkedHashSet
    10  func main() {
    11  	set := linkedhashset.New() // empty
    12  	set.Add(5)                 // 5
    13  	set.Add(4, 4, 3, 2, 1)     // 5, 4, 3, 2, 1 (in insertion-order, duplicates ignored)
    14  	set.Remove(4)              // 5, 3, 2, 1 (in insertion-order)
    15  	set.Remove(2, 3)           // 5, 1 (in insertion-order)
    16  	set.Contains(1)            // true
    17  	set.Contains(1, 5)         // true
    18  	set.Contains(1, 6)         // false
    19  	_ = set.Values()           // []int{5, 1} (in insertion-order)
    20  	set.Clear()                // empty
    21  	set.Empty()                // true
    22  	set.Size()                 // 0
    23  }