Files
gf/container/gmap/gmap.go

46 lines
1.8 KiB
Go
Raw Normal View History

2021-01-17 21:46:25 +08:00
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
2018-01-03 10:38:53 +08:00
//
// This Source Code Form is subject to the terms of the MIT License.
2019-02-01 17:30:23 +08:00
// If a copy of the MIT was not distributed with gm file,
// You can obtain one at https://github.com/gogf/gf.
2018-01-03 10:38:53 +08:00
2020-05-22 12:04:58 +08:00
// Package gmap provides most commonly used map container which also support concurrent-safe/unsafe switch feature.
2018-01-03 10:38:53 +08:00
package gmap
type (
Map = AnyAnyMap // Map is alias of AnyAnyMap.
HashMap = AnyAnyMap // HashMap is alias of AnyAnyMap.
)
2019-11-30 18:33:51 +08:00
// New creates and returns an empty hash map.
// The parameter `safe` is used to specify whether using map in concurrent-safety,
// which is false in default.
func New(safe ...bool) *Map {
return NewAnyAnyMap(safe...)
}
// NewFrom creates and returns a hash map from given map `data`.
// Note that, the param `data` map will be set as the underlying data map(no deep copy),
// there might be some concurrent-safe issues when changing the map outside.
// The parameter `safe` is used to specify whether using tree in concurrent-safety,
// which is false in default.
func NewFrom(data map[interface{}]interface{}, safe ...bool) *Map {
return NewAnyAnyMapFrom(data, safe...)
2019-05-09 22:53:42 +08:00
}
2019-11-30 18:33:51 +08:00
// NewHashMap creates and returns an empty hash map.
// The parameter `safe` is used to specify whether using map in concurrent-safety,
// which is false in default.
func NewHashMap(safe ...bool) *Map {
return NewAnyAnyMap(safe...)
}
// NewHashMapFrom creates and returns a hash map from given map `data`.
// Note that, the param `data` map will be set as the underlying data map(no deep copy),
// there might be some concurrent-safe issues when changing the map outside.
// The parameter `safe` is used to specify whether using tree in concurrent-safety,
// which is false in default.
func NewHashMapFrom(data map[interface{}]interface{}, safe ...bool) *Map {
return NewAnyAnyMapFrom(data, safe...)
2019-06-19 09:06:52 +08:00
}