linkedhashmap

package module
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 22, 2021 License: MIT Imports: 5 Imported by: 0

README

Build Status GitHub release go.dev reference 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()

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Element

type Element struct {
	Key   interface{}
	Value interface{}
}

Element represents linked hashmap element

type LinkedHashMap

type LinkedHashMap struct {
	// contains filtered or unexported fields
}

LinkedHashMap represents linked hashmap entity

func NewLinkedHashMap

func NewLinkedHashMap() *LinkedHashMap

NewLinkedHashMap create LinkedHashMap pointer

func (*LinkedHashMap) Get

func (jc *LinkedHashMap) Get(key interface{}) interface{}

Get gets a element from linked hashmap

func (*LinkedHashMap) Iter

func (jc *LinkedHashMap) Iter() <-chan *Element

Iter iterates over each elements of linked hashmap

func (*LinkedHashMap) Keys

func (jc *LinkedHashMap) Keys() []interface{}

Keys gets all keys of linked hashmap

func (*LinkedHashMap) Put

func (jc *LinkedHashMap) Put(key, value interface{})

Put puts a new element into linked hashmap

func (*LinkedHashMap) Remove

func (jc *LinkedHashMap) Remove(key interface{})

Remove removes a element from linked hashmap

func (*LinkedHashMap) SortKeyAsc added in v0.1.1

func (jc *LinkedHashMap) SortKeyAsc()

SortKeyAsc sorts linked hashmap ascending order with key

func (*LinkedHashMap) SortKeyDesc added in v0.1.1

func (jc *LinkedHashMap) SortKeyDesc()

SortKeyDesc sorts linked hashmap descending order with key

func (*LinkedHashMap) SortValueAsc added in v0.1.1

func (jc *LinkedHashMap) SortValueAsc()

SortValueAsc sorts linked hashmap ascending order with value

func (*LinkedHashMap) SortValueDesc added in v0.1.1

func (jc *LinkedHashMap) SortValueDesc()

SortValueDesc sorts linked hashmap descending order with value

func (*LinkedHashMap) Values

func (jc *LinkedHashMap) Values() []interface{}

Values gets all values of linked hashmap

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL