Skip to content

Instantly share code, notes, and snippets.

@mhshams
Created February 1, 2016 14:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhshams/a3ccc072ca40c9339058 to your computer and use it in GitHub Desktop.
Save mhshams/a3ccc072ca40c9339058 to your computer and use it in GitHub Desktop.
/**
* A Set is a data structure that contains multiple (zero or more) elements.
* - The elements in the Set are unique. (no duplication)
* - The elements in the Set are not kept in given order. (unordered)
*/
class MySet {
/**
* This property shows the number of elements that are currently available in the Set.
*/
var size: Int = 0
/**
* Checks if the Set is empty.
*
* @return true if the Set is empty, false otherwise
*/
fun isEmpty(): Boolean = false
/**
* Checks if the given integer is available in the Set.
*
* @return true if the given element is available in the Set, false otherwise
*/
fun contains(i: Int): Boolean = false
/**
* Adds a new element to the Set.
*
* @return true if the element was not already in the Set, false otherwise
*/
fun add(i: Int): Boolean = false
/**
* Removes the given element from the Set.
*
* @return true if the elements was in the Set, false otherwise
*/
fun remove(i: Int): Boolean = false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment