Add javadocs
This commit is contained in:
parent
9f99de7c9e
commit
b3e470ac0e
1 changed files with 14 additions and 0 deletions
|
|
@ -12,6 +12,12 @@ public class Sequence<T> {
|
||||||
this.previous = new LinkedList<T>();
|
this.previous = new LinkedList<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds an element to the sequence. If the sequence contains the maximum amount
|
||||||
|
* of elements, it will remove the first element from the sequence.
|
||||||
|
*
|
||||||
|
* @param e The element to add to the sequence
|
||||||
|
*/
|
||||||
public void add(T e) {
|
public void add(T e) {
|
||||||
if (this.previous.size() == this.max) {
|
if (this.previous.size() == this.max) {
|
||||||
this.previous.pop();
|
this.previous.pop();
|
||||||
|
|
@ -19,10 +25,18 @@ public class Sequence<T> {
|
||||||
this.previous.add(e);
|
this.previous.add(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides info on how many elements are currently in the sequence.
|
||||||
|
*
|
||||||
|
* @return The number of elements in the sequence
|
||||||
|
*/
|
||||||
public Integer size() {
|
public Integer size() {
|
||||||
return this.previous.size();
|
return this.previous.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines if all of the elements in the sequence are unique or not.
|
||||||
|
*/
|
||||||
public Boolean isUnique() {
|
public Boolean isUnique() {
|
||||||
HashSet<T> s = new HashSet<>();
|
HashSet<T> s = new HashSet<>();
|
||||||
for (T e : this.previous) {
|
for (T e : this.previous) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue