datastructure

package
v0.0.0-...-654d6e8 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

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

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

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

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

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

func (hm *HashMap) Size() uint64

Size returns current size of Hashmap

func (*HashMap) Values

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