2019-05-08 17:21:18 +08:00
|
|
|
// Copyright 2017 gf Author(https://github.com/gogf/gf). 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,
|
2019-02-02 16:18:25 +08:00
|
|
|
// You can obtain one at https://github.com/gogf/gf.
|
2018-01-03 10:38:53 +08:00
|
|
|
|
2019-05-11 20:47:25 +08:00
|
|
|
// Package gmap provides concurrent-safe/unsafe map containers.
|
2018-01-03 10:38:53 +08:00
|
|
|
package gmap
|
2019-05-08 17:21:18 +08:00
|
|
|
|
2019-05-11 20:47:25 +08:00
|
|
|
// Map based on hash table, alias of AnyAnyMap.
|
2019-06-19 09:06:52 +08:00
|
|
|
type Map = AnyAnyMap
|
2019-05-11 20:47:25 +08:00
|
|
|
type HashMap = AnyAnyMap
|
|
|
|
|
|
2019-05-08 17:21:18 +08:00
|
|
|
// New returns an empty hash map.
|
2019-06-11 20:57:43 +08:00
|
|
|
// The parameter <unsafe> used to specify whether using map in un-concurrent-safety,
|
2019-05-08 17:21:18 +08:00
|
|
|
// which is false in default, means concurrent-safe.
|
|
|
|
|
func New(unsafe ...bool) *Map {
|
2019-05-11 20:47:25 +08:00
|
|
|
return NewAnyAnyMap(unsafe...)
|
2019-05-08 17:21:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NewFrom returns a hash map from given map <data>.
|
2019-05-11 20:47:25 +08:00
|
|
|
// Note that, the param <data> map will be set as the underlying data map(no deep copy),
|
2019-05-08 17:21:18 +08:00
|
|
|
// there might be some concurrent-safe issues when changing the map outside.
|
2019-06-11 20:57:43 +08:00
|
|
|
// The parameter <unsafe> used to specify whether using tree in un-concurrent-safety,
|
2019-05-11 20:47:25 +08:00
|
|
|
// which is false in default.
|
2019-06-19 09:06:52 +08:00
|
|
|
func NewFrom(data map[interface{}]interface{}, unsafe ...bool) *Map {
|
2019-05-11 20:47:25 +08:00
|
|
|
return NewAnyAnyMapFrom(data, unsafe...)
|
2019-05-09 22:53:42 +08:00
|
|
|
}
|
|
|
|
|
|
2019-05-11 20:47:25 +08:00
|
|
|
// NewHashMap returns an empty hash map.
|
2019-06-11 20:57:43 +08:00
|
|
|
// The parameter <unsafe> used to specify whether using map in un-concurrent-safety,
|
2019-05-11 20:47:25 +08:00
|
|
|
// which is false in default, means concurrent-safe.
|
|
|
|
|
func NewHashMap(unsafe ...bool) *Map {
|
|
|
|
|
return NewAnyAnyMap(unsafe...)
|
2019-05-08 17:21:18 +08:00
|
|
|
}
|
|
|
|
|
|
2019-05-11 20:47:25 +08:00
|
|
|
// NewHashMapFrom 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.
|
2019-06-11 20:57:43 +08:00
|
|
|
// The parameter <unsafe> used to specify whether using tree in un-concurrent-safety,
|
2019-05-11 20:47:25 +08:00
|
|
|
// which is false in default.
|
2019-06-19 09:06:52 +08:00
|
|
|
func NewHashMapFrom(data map[interface{}]interface{}, unsafe ...bool) *Map {
|
2019-05-11 20:47:25 +08:00
|
|
|
return NewAnyAnyMapFrom(data, unsafe...)
|
2019-06-19 09:06:52 +08:00
|
|
|
}
|