github.com/zhongdalu/gf@v1.0.0/g/container/gmap/gmap.go (about)

     1  // Copyright 2017 gf Author(https://github.com/zhongdalu/gf). All Rights Reserved.
     2  //
     3  // This Source Code Form is subject to the terms of the MIT License.
     4  // If a copy of the MIT was not distributed with gm file,
     5  // You can obtain one at https://github.com/zhongdalu/gf.
     6  
     7  // Package gmap provides concurrent-safe/unsafe map containers.
     8  package gmap
     9  
    10  // Map based on hash table, alias of AnyAnyMap.
    11  type Map = AnyAnyMap
    12  type HashMap = AnyAnyMap
    13  
    14  // New returns an empty hash map.
    15  // The parameter <unsafe> used to specify whether using map in un-concurrent-safety,
    16  // which is false in default, means concurrent-safe.
    17  func New(unsafe ...bool) *Map {
    18  	return NewAnyAnyMap(unsafe...)
    19  }
    20  
    21  // NewFrom returns a hash map from given map <data>.
    22  // Note that, the param <data> map will be set as the underlying data map(no deep copy),
    23  // there might be some concurrent-safe issues when changing the map outside.
    24  // The parameter <unsafe> used to specify whether using tree in un-concurrent-safety,
    25  // which is false in default.
    26  func NewFrom(data map[interface{}]interface{}, unsafe ...bool) *Map {
    27  	return NewAnyAnyMapFrom(data, unsafe...)
    28  }
    29  
    30  // NewHashMap returns an empty hash map.
    31  // The parameter <unsafe> used to specify whether using map in un-concurrent-safety,
    32  // which is false in default, means concurrent-safe.
    33  func NewHashMap(unsafe ...bool) *Map {
    34  	return NewAnyAnyMap(unsafe...)
    35  }
    36  
    37  // NewHashMapFrom returns a hash map from given map <data>.
    38  // Note that, the param <data> map will be set as the underlying data map(no deep copy),
    39  // there might be some concurrent-safe issues when changing the map outside.
    40  // The parameter <unsafe> used to specify whether using tree in un-concurrent-safety,
    41  // which is false in default.
    42  func NewHashMapFrom(data map[interface{}]interface{}, unsafe ...bool) *Map {
    43  	return NewAnyAnyMapFrom(data, unsafe...)
    44  }