| 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 maps provides an abstract Map interface. |
| 6 | // |
| 7 | // In computer science, an associative array, map, symbol table, or dictionary is an abstract data type composed of a collection of (key, value) pairs, such that each possible key appears just once in the collection. |
| 8 | // |
| 9 | // Operations associated with this data type allow: |
| 10 | // - the addition of a pair to the collection |
| 11 | // - the removal of a pair from the collection |
| 12 | // - the modification of an existing pair |
| 13 | // - the lookup of a value associated with a particular key |
| 14 | // |
| 15 | // Reference: https://en.wikipedia.org/wiki/Associative_array |
| 16 | package maps |
| 17 | |
| 18 | import "github.com/emirpasic/gods/v2/containers" |
| 19 | |
| 20 | // Map interface that all maps implement |
| 21 | type Map[K comparable, V any] interface { |
| 22 | Put(key K, value V) |
| 23 | Get(key K) (value V, found bool) |
| 24 | Remove(key K) |
| 25 | Keys() []K |
| 26 | |
| 27 | containers.Container[V] |
| 28 | // Empty() bool |
| 29 | // Size() int |
| 30 | // Clear() |
| 31 | // Values() []interface{} |
| 32 | // String() string |
| 33 | } |
| 34 | |
| 35 | // BidiMap interface that all bidirectional maps implement (extends the Map interface) |
| 36 | type BidiMap[K comparable, V comparable] interface { |
| 37 | GetKey(value V) (key K, found bool) |
| 38 | |
| 39 | Map[K, V] |
| 40 | } |