Skip to content

howood/linkedhashmap

Repository files navigation

GitHub release go.dev reference Build Status Test Coverage Go Report Card MIT License

linkedhashmap

LinkedHashMap provides map with order of elements.

Install

$ go get -u github.com/howood/linkedhashmap

Usage

	// Create new
	lMap := NewLinkedHashMap()

	// Set map data
	lMap.Put("tokyo", 3)
	lMap.Put("yokohama", 23)
	lMap.Put("kyoto", 44)
	lMap.Put("sapporo", 65)
	lMap.Put("fukuoka", 76)

	// Get map data
	val := lMap.Get("sendai") // interface{}

	// Remove map data
	lMap.Remove("sapporo")

	// Get all keys and values
	keys := lMap.Keys()
	values := lMap.Values()

	// Itretor
	for lm := range lMap.Iter() {
		log.Printf("%v: %v", lm.Key, lm.Value)
	}

	// Sort with key
	lMap.SortKeyAsc()
	lMap.SortKeyDesc()

	// Sort with value
	lMap.SortValueAsc()
	lMap.SortValueDesc()

About

LinkedHashMap provides map with order of elements.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages