Skip to content

ExtendedMap is a generic map implementation in Go that provides additional functionalities such as Push, Set, Pop, Get, and Sort. It leverages Go's generics to provide a type-safe and flexible map structure.

Notifications You must be signed in to change notification settings

sdn0303/extended_map

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ExtendedMap in Go

ExtendedMap is a generic map implementation in Go that provides additional functionalities such as Push, Set, Pop, Get, and Sort. It leverages Go's generics to provide a type-safe and flexible map structure.

Features

  • Push: Adds a new key-value pair to the map.
  • Set: Updates the value of an existing key.
  • Get: Retrieves the value of a given key.
  • Pop: Removes a key-value pair from the map.
  • Sort: Returns a sorted slice of key-value pairs.

Usage

Importing the Package

Make sure to include the ExtendedMap implementation in your project.

Creating a New ExtendedMap

m := NewExtendedMap[string, int]()

Adding Key-Value Pairs

m.Push("a", 10)
m.Push("b", 20)

Updating a Value

m.Set("a", 30)

Retrieving a Value

value, exists := m.Get("a")

Removing a Key-Value Pair

value, exists := m.Pop("a")

Sorting Key-Value Pairs

sortedPairs := m.Sort()

About

ExtendedMap is a generic map implementation in Go that provides additional functionalities such as Push, Set, Pop, Get, and Sort. It leverages Go's generics to provide a type-safe and flexible map structure.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages