Skip to content

Commit

Permalink
Fix some old code issue
Browse files Browse the repository at this point in the history
  • Loading branch information
BigEgg committed Jul 23, 2018
1 parent 0b770d9 commit 987f2a2
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 15 deletions.
7 changes: 0 additions & 7 deletions java/Algorithms/src/Collections/LinkedBag.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public LinkedBag() {
*
* @return true if this bag is empty; false otherwise
*/
@Override
public boolean isEmpty() {
return first == null;
}
Expand All @@ -35,7 +34,6 @@ public boolean isEmpty() {
*
* @return the number of items in this bag
*/
@Override
public int size() {
return N;
}
Expand All @@ -46,7 +44,6 @@ public int size() {
* @param item the item to add to this bag
* @throws NullPointerException if the <tt>item</tt> is null;
*/
@Override
public void add(Item item) {
if (item == null) throw new NullPointerException();
Node oldFisrt = first;
Expand Down Expand Up @@ -75,28 +72,24 @@ public String toString() {
*
* @return an iterator that iterates over the items in this bag
*/
@Override
public Iterator<Item> iterator() {
return new LinkedBagIterator();
}

private class LinkedBagIterator implements Iterator<Item> {
private Node current = first;

@Override
public boolean hasNext() {
return current != null;
}

@Override
public Item next() {
if (!hasNext()) throw new NoSuchElementException();
Item result = current.item;
current = current.next;
return result;
}

@Override
public void remove() {
throw new UnsupportedOperationException();
}
Expand Down
7 changes: 0 additions & 7 deletions java/Algorithms/src/Collections/ResizingArrayBag.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public ResizingArrayBag() {
*
* @return true if this bag is empty; false otherwise
*/
@Override
public boolean isEmpty() {
return N == 0;
}
Expand All @@ -30,7 +29,6 @@ public boolean isEmpty() {
*
* @return the number of items in this bag
*/
@Override
public int size() {
return N;
}
Expand All @@ -54,7 +52,6 @@ private void resize(int capacity) {
* @param item the item to add to this bag
* @throws NullPointerException if the <tt>item</tt> is null;
*/
@Override
public void add(Item item) {
if (item == null) throw new NullPointerException();
if (N == a.length) resize(a.length * 2);
Expand All @@ -80,26 +77,22 @@ public String toString() {
*
* @return an iterator that iterates over the items in this bag
*/
@Override
public Iterator<Item> iterator() {
return new ResizingArrayBagIterator();
}

private class ResizingArrayBagIterator implements Iterator<Item> {
private int currnet = 0;

@Override
public boolean hasNext() {
return currnet < N;
}

@Override
public Item next() {
if (!hasNext()) throw new NoSuchElementException();
return a[currnet++];
}

@Override
public void remove() {
throw new UnsupportedOperationException();
}
Expand Down
1 change: 0 additions & 1 deletion java/Algorithms/src/UnionFinds/UnionFind.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public UnionFind(int N) throws IllegalArgumentException {
*
* @return the number of components (between 1 and N)
*/
@Override
public int count() {
return count;
}
Expand Down

0 comments on commit 987f2a2

Please sign in to comment.