Introduction
A map
container with a concurrent safety switch option, the most commonly used data structure. This module includes map
containers with multiple data structures: HashMap
, TreeMap
, and ListMap
.
Type | Data Structure | Average Complexity | Supports Sorting | Ordered Traversal | Description |
---|---|---|---|---|---|
HashMap | Hash Table | O(1) | No | No | High performance read/write operation, high memory usage, random traversal |
ListMap | Hash Table + Doubly Linked List | O(2) | No | Yes | Supports traversal in the order of insertion, high memory usage |
TreeMap | Red Black Tree | O(log N) | Yes | Yes | Compact memory usage, supports key name sorting and ordered traversal |
Additionally, the gmap
module supports defining common types of map
with hash table as the underlying data structure: IntIntMap
, IntStrMap
, IntAnyMap
, StrIntMap
, StrStrMap
, StrAnyMap
.
Usage Scenarios:
Any map
/hash table/associative array usage scenario, particularly in concurrent safety scenarios.
Usage Method:
import "github.com/gogf/gf/v2/container/gmap"
Interface Documentation:
https://pkg.go.dev/github.com/gogf/gf/v2/container/gmap
Documents
📄️ Map - Usage
Basic usage of the gmap module under the GoFrame framework, including switching operations of concurrent security features, setting, querying, and deleting key-value pairs, as well as ordered traversal, serialization and deserialization of data structures, with detailed code examples and execution results.
📄️ Map - Performance
Detailed testing and analysis of the performance of dictionary types. By comparing the performance of gmap in the GoFrame framework with the standard library's sync.Map, the efficiency in different scenarios of concurrent safety and non-concurrent safety is revealed. Includes performance benchmarking of different types of maps such as HashMap, ListMap, and TreeMap, providing developers with real-time reference for optimizing applications.
📄️ Map - Methods
Various methods of the AnyAnyMap in the GoFrame framework, including operations such as creation, cloning, iteration, setting, deletion, and merging. Code examples are provided to help understand the use of these methods to ensure concurrency safety. For more detailed information, refer to the GoFrame Framework documentation.