0
0
Fork 0

Add javadocs

This commit is contained in:
Oliver Akins 2022-12-08 21:56:00 -06:00
parent 9f99de7c9e
commit b3e470ac0e
No known key found for this signature in database
GPG key ID: 3C2014AF9457AF99

View file

@ -12,6 +12,12 @@ public class Sequence<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) {
if (this.previous.size() == this.max) {
this.previous.pop();
@ -19,10 +25,18 @@ public class Sequence<T> {
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() {
return this.previous.size();
}
/**
* Determines if all of the elements in the sequence are unique or not.
*/
public Boolean isUnique() {
HashSet<T> s = new HashSet<>();
for (T e : this.previous) {