Add ArrayMap/ArraySet (slice-backed ordered map/set) and integrate into ds package#3
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
ArrayMapbacked by a sorted slice.ArraySetbuilt on top ofArrayMapto offer ordered set semantics and common set-algebra operations (Union,Intersection,Difference,SymmetricDifference, etc.).dspackage and update docs/examples to advertise the new, lightweight ordered collection options.Description
arraymappackage implementingArrayMapwith core operations,EntryAPI (OrInsert,AndModify,Insert,Delete), range/iteration support (IterAsc,IterDesc,RangeAsc,RangeDesc, mutable variants), and helper constructorsNew,NewOrdered, andNewFromMap(files:arraymap.go,entry.go,iter.go,doc.go).arraysetpackage implementingArraySetbacked byArrayMap, including ordering, range iteration, set algebra methods, and convenience constructors (files:arrayset.go,iter.go,doc.go).dspackage by adding aliases and constructors such asArrayMap,NewArrayMap,NewOrderedArrayMap,ArraySet,NewArraySet, andNewOrderedArraySet, and reorganized some doc exports inds.goto include the new structures.README.mdand package docs to listArrayMap/ArraySetand added a small example showing usage withcmp.Compare.Testing
go test ./...across the module and the test suite completed successfully.arraymap(arraymap_test.go) covering ordering, entry API, iteration, range/mutation, cloning/clearing, and constructors, and all tests passed.arrayset(arrayset_test.go) covering basic operations, ordering and ranges, set algebra, and clone semantics, and all tests passed.Codex Task