Coder Social home page Coder Social logo

advanced-sets's Introduction

Hi there ๐Ÿ‘‹

My name is JP, I'm currently a backend .NET developer at Draftkings. In my free time, I like to work on web projects.

Anurag's github stats

advanced-sets's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

advanced-sets's Issues

.powerSet()

It'd be nice to have a method that returns an array, or iterable, of sets that are all the permutations of the elements of the set (a.k.a. the power set)

e.g.

const setA = new AdvancedSet(1, 2, 3)
setA.powerSet() // [AS(), AS(1), AS(2), AS(3), AS(1, 2), AS(1, 3), AS(2, 3), AS(1, 2, 3)]

Create subset by condition

It'd be nice to have createSubset be able to take in the list of values (current) or a condition function that defines what elements to keep

Proper subsets and supersets

There are methods to check if another set is a subset and superset, so there should also be methods that check for proper subsets and proper supersets

Support varargs .add()

Currently, .add() only accepts one argument. It should be able to accept any number of arguments.

Too much temporary data and inefficient operations

Consider using the standard .values instead of the custom .toArray. Besides, I'd also suggest to use Set's methods as much as possible since it is implemented as a hashset, which is very efficient, instead of relying on Array's methods which usually take at least linear time.

For example, .intersection could be implemented along the following lines

intersection(s1, s2) {
  s3 = new Set();
  s1.forEach(value => {
    if (s2.has(value)) {
      s3.add(value);
    }
  });
  return s3;
}

Allow for multi set intersection

Current behavior:
Can only find the intersection between two sets

setA.intersection(setB)

Desired behavior:
Find the intersection between n sets

setA.interesction(setB, setC, setD, ...)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.