github.com/mymmsc/gox@v1.3.33/util/examples/linkedhashmap/linkedhashmap.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 "github.com/mymmsc/gox/util/linkedhashmap" 8 9 // LinkedHashMapExample to demonstrate basic usage of LinkedHashMapExample 10 func main() { 11 m := linkedhashmap.New() // empty (keys are of type int) 12 m.Put(2, "b") // 2->b 13 m.Put(1, "x") // 2->b, 1->x (insertion-order) 14 m.Put(1, "a") // 2->b, 1->a (insertion-order) 15 _, _ = m.Get(2) // b, true 16 _, _ = m.Get(3) // nil, false 17 _ = m.Values() // []interface {}{"b", "a"} (insertion-order) 18 _ = m.Keys() // []interface {}{2, 1} (insertion-order) 19 m.Remove(1) // 2->b 20 m.Clear() // empty 21 m.Empty() // true 22 m.Size() // 0 23 }