datastructure

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: MIT Imports: 3 Imported by: 2

Documentation

Overview

Package datastructure implements some data structure. hashmap structure.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HashMap

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

HashMap implements a hash map

func NewHashMap

func NewHashMap() *HashMap

NewHashMap return a HashMap instance

func NewHashMapWithCapacity

func NewHashMapWithCapacity(size, capacity uint64) *HashMap

NewHashMapWithCapacity return a HashMap instance with given size and capacity

func (*HashMap) Contains

func (hm *HashMap) Contains(key any) bool

Contains checks if given key is in hashmap or not

func (*HashMap) Delete

func (hm *HashMap) Delete(key any)

Delete item by given key in hashmap

func (*HashMap) FilterByValue added in v2.3.0

func (hm *HashMap) FilterByValue(perdicate func(value any) bool) *HashMap

FilterByValue returns a filtered HashMap. If any value is not matching the perdicate function then it returns nil otherwise it returns the HashMap with selected values.

func (*HashMap) Get

func (hm *HashMap) Get(key any) any

Get return the value of given key in hashmap

func (*HashMap) GetOrDefault added in v2.2.5

func (hm *HashMap) GetOrDefault(key any, defaultValue any) any

GetOrDefault return the value of given key in hashmap, if not found return default value

func (*HashMap) Iterate added in v2.1.7

func (hm *HashMap) Iterate(iteratee func(key, value any))

Iterate executes iteratee funcation for every key and value pair of hashmap (random order)

func (*HashMap) Keys added in v2.1.7

func (hm *HashMap) Keys() []any

Keys returns a slice of the hashmap's keys (random order)

func (*HashMap) Put

func (hm *HashMap) Put(key any, value any)

Put new key value in hashmap

func (*HashMap) Size added in v2.3.0

func (hm *HashMap) Size() uint64

Size returns current size of Hashmap

func (*HashMap) Values added in v2.1.7

func (hm *HashMap) Values() []any

Values returns a slice of the hashmap's keys (random order)

Jump to

Keyboard shortcuts

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