Debian Codegraph @

examples/hashbidimap/hashbidimap.go

raw symbols SCIP
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/emirpasic/gods/v2/maps/hashbidimap"
8
9 // HashBidiMapExample to demonstrate basic usage of HashMap
10 func main() {
11 m := hashbidimap.New[int, string]() // empty
12 m.Put(1, "x") // 1->x
13 m.Put(3, "b") // 1->x, 3->b (random order)
14 m.Put(1, "a") // 1->a, 3->b (random order)
15 m.Put(2, "b") // 1->a, 2->b (random order)
16 _, _ = m.GetKey("a") // 1, true
17 _, _ = m.Get(2) // b, true
18 _, _ = m.Get(3) // nil, false
19 _ = m.Values() // []interface {}{"a", "b"} (random order)
20 _ = m.Keys() // []interface {}{1, 2} (random order)
21 m.Remove(1) // 2->b
22 m.Clear() // empty
23 m.Empty() // true
24 m.Size() // 0
25 }