Giter Site home page Giter Site logo

randomsetbuilder's Introduction

RandomSetBuilder

RandomSetBuilder - is a class that builds you set of random numbers from the range

How to

Creating object

To create an object of RandomSetBuilder use parameters min, max and seed. The range will be from min to max - 1.
Parameters min and seed are optional. By default min = 0 and seed = System.currentTimeMillis().

Code example:

RandomSetBuilder randomSetBuilder = new RandomSetBuilder(0, 10);

Adding numbers to the set (building)

append(int count)

To add some numbers to the set use append(int count) method. If count is more than number of integers that can be added, than only available number of integers will be added.

Code example:

RandomSetBuilder randomSetBuilder = new RandomSetBuilder(0, 10);

randomSetBuilder.append(3);   // add 3 unique integers from the range [0, 9], 7 left unused
randomSetBuilder.append(2);   // add 2 unique integers from the range [0, 9], 5 left unused
randomSetBuilder.append(100); // add 5 unique integers from the range [0, 9], 0 left unused
randomSetBuilder.append(100); // add 0 unique integers from the range [0, 9], 0 left unused

appendAll()

If you want to add all the rest unused integers use appendAll() method.

Code example:

RandomSetBuilder randomSetBuilder = new RandomSetBuilder(0, 10);

randomSetBuilder.append(3);    // add 3 unique integers from the range [0, 9], 7 left unused
randomSetBuilder.append(2);    // add 2 unique integers from the range [0, 9], 5 left unused
randomSetBuilder.appendAll();  // add 5 unique integers from the range [0, 9], 0 left unused

Getting building result

As the result you can get List, Set, Queue, Deque or integer array

Code example:

Set<Integer> randomSet = randomSetBuilder.toSet();
List<Integer> randomList = randomSetBuilder.toList();
Queue<Integer> randomQueue = randomSetBuilder.toQueue();
Deque<Integer> randomDeque = randomSetBuilder.toDeque();
int[] randomArray = randomSetBuilder.toArray();

randomsetbuilder's People

Contributors

smartoven avatar

Watchers

James Cloos avatar  avatar

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.