-
Notifications
You must be signed in to change notification settings - Fork 162
Open
Labels
Description
Hey all,
I was trying to test out some stuff from #80, and rather than changing up everyone's work on the Matrix data structure, I thought I'd give Set a try. The reason this is not a PR is that there is still work to be done (namely testing and potential problems below).
problems with Set currently:
- Should you store an array of elements in the set?
(rather than creating it from Object.keys() each time the values are necessary). - Can a set contain any arbitrary shallow js object?
(If not this should be redeveloped to work more efficiently with numbers only).
My bias is for Set to work with JSON (potentially too large of an overhead)
and objects developed within the library. Set will be primarily useful for
working with numbers, but has a lot of strength as a basic data structure.
(I use it all the time in python) - Should this extend to deep objects? (arrays) (should deep checks occur).
This becomes problematic when working with the methods that accept input
from multiple types (basically the developer would have to wrap any arrays that they'd
like to add to a set in another array, and the functions below would need to be changed). - Should remove be part of the method chaining and not return true | false?
My recommendation is to have it be part of method chaining and then have the static method return T/F.
There's some code repetition but it helps keep the API following a similar structure.
And if someone needs to determine if all were in the set then they could do:
if (number.set.remove(A, [1,2,3]).reduce(function(a, b) { return !!a && !!b; }))
A.remove([1,2,3]); - Should Set be an extension of the Array object? If so we will likely come into insertion
complications (a self balancing binary search tree or a trie, handled in a javascript array
could cause a lot of array recreation). It might be possible to extend the Array object and
contain similar logic laid out below (see 1). This is also useful because we could implement:
map, reduce, splice, join, etc. on the set with minimal effort. - Any //TODO seen in the commit linked below.
Reactions are currently unavailable