Skip to main content
Version: 2.8.x(Latest)

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.

TypeData StructureAverage ComplexitySupports SortingOrdered TraversalDescription
HashMapHash TableO(1)NoNoHigh performance read/write operation, high memory usage, random traversal
ListMapHash Table + Doubly Linked ListO(2)NoYesSupports traversal in the order of insertion, high memory usage
TreeMapRed Black TreeO(log N)YesYesCompact memory usage, supports key name sorting and ordered traversal
tip

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