Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
github.com/mitranim/gord
Go ordered sets.
Features:
LinkedSet
: ordered set with near-constant-time (O(1)) performance for inserting, deleting, and moving elements. Backed by a map and a doubly-linked list.
SyncLinkedSet
: concurrency-safe LinkedSet
, slightly slower.
SliceSet
: slice-backed ordered set. Simpler and faster for small sets, extreme performance degradation for large sets.
All implementations share a common interface.
Small with no dependencies.
See the documentation at https://godoc.org/github.com/mitranim/gord.
Example:
import "github.com/mitranim/gord"
set := gord.NewOrdSet()
// Note the order.
set.Add(20)
set.Add(10)
set.Add(30)
// Redundant and doesn't change the order.
set.Add(30)
set.Add(10)
set.Add(20)
set.Has(10) // true
set.Has(40) // false
set.Values() // []interface{}{20, 10, 30}
set.PopFirst() // 20
set.PopLast() // 30
set.Values() // []interface{}{10}
Has room for performance optimizations.
LinkedSet
and SyncLinkedSet
don't expose a way to iterate over elements without allocating a slice via .Values()
. Can be rectified on demand.
I'm receptive to suggestions. If this library almost satisfies you but needs changes, open an issue or chat me up. Contacts: https://mitranim.com/#contacts
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.