Created
February 1, 2016 14:37
-
-
Save mhshams/a3ccc072ca40c9339058 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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