Skip to content

How Should We Implement Set and a first look at how potential API changes impact code. #84

@milroc

Description

@milroc

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:

  1. Should you store an array of elements in the set?
    (rather than creating it from Object.keys() each time the values are necessary).
  2. 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)
  3. 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).
  4. 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]);
  5. 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.
  6. Any //TODO seen in the commit linked below.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions