github.com/mymmsc/gox@v1.3.33/util/maps.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 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 util
    17  
    18  // Map interface that all maps implement
    19  type Map interface {
    20  	Put(key interface{}, value interface{})
    21  	Get(key interface{}) (value interface{}, found bool)
    22  	Remove(key interface{})
    23  	Keys() []interface{}
    24  
    25  	Container
    26  	// Empty() bool
    27  	// Size() int
    28  	// Clear()
    29  	// Values() []interface{}
    30  }
    31  
    32  // BidiMap interface that all bidirectional maps implement (extends the Map interface)
    33  type BidiMap interface {
    34  	GetKey(value interface{}) (key interface{}, found bool)
    35  
    36  	Map
    37  }