github.com/gogf/gf/v2@v2.7.4/container/gmap/gmap.go (about) 1 // Copyright GoFrame Author(https://goframe.org). 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/gogf/gf. 6 7 // Package gmap provides most commonly used map container which also support concurrent-safe/unsafe switch feature. 8 package gmap 9 10 type ( 11 Map = AnyAnyMap // Map is alias of AnyAnyMap. 12 HashMap = AnyAnyMap // HashMap is alias of AnyAnyMap. 13 ) 14 15 // New creates and returns an empty hash map. 16 // The parameter `safe` is used to specify whether using map in concurrent-safety, 17 // which is false in default. 18 func New(safe ...bool) *Map { 19 return NewAnyAnyMap(safe...) 20 } 21 22 // NewFrom creates and returns a hash map from given map `data`. 23 // Note that, the param `data` map will be set as the underlying data map(no deep copy), 24 // there might be some concurrent-safe issues when changing the map outside. 25 // The parameter `safe` is used to specify whether using tree in concurrent-safety, 26 // which is false in default. 27 func NewFrom(data map[interface{}]interface{}, safe ...bool) *Map { 28 return NewAnyAnyMapFrom(data, safe...) 29 } 30 31 // NewHashMap creates and returns an empty hash map. 32 // The parameter `safe` is used to specify whether using map in concurrent-safety, 33 // which is false in default. 34 func NewHashMap(safe ...bool) *Map { 35 return NewAnyAnyMap(safe...) 36 } 37 38 // NewHashMapFrom creates and returns a hash map from given map `data`. 39 // Note that, the param `data` map will be set as the underlying data map(no deep copy), 40 // there might be some concurrent-safe issues when changing the map outside. 41 // The parameter `safe` is used to specify whether using tree in concurrent-safety, 42 // which is false in default. 43 func NewHashMapFrom(data map[interface{}]interface{}, safe ...bool) *Map { 44 return NewAnyAnyMapFrom(data, safe...) 45 }