Skip to content

Commit

Permalink
Added clear method to Library.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Gramlich committed Dec 12, 2012
1 parent dd80a3d commit 665d86b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/org/andengine/util/adt/map/Library.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,25 @@ public Library(final int pInitialCapacity) {
// Getter & Setter
// ===========================================================

public T get(final int pID) {
return this.mItems.get(pID);
}

public void put(final int pID, final T pItem) {
final T existingItem = this.mItems.get(pID);
if(existingItem == null) {
final T item = this.mItems.get(pID);
if(item == null) {
this.mItems.put(pID, pItem);
} else {
throw new IllegalArgumentException("ID: '" + pID + "' is already associated with item: '" + existingItem.toString() + "'.");
throw new IllegalArgumentException("ID: '" + pID + "' is already associated with item: '" + item.toString() + "'.");
}
}

public void remove(final int pID) {
this.mItems.remove(pID);
}

public T get(final int pID) {
return this.mItems.get(pID);
public void clear() {
this.mItems.clear();
}

// ===========================================================
Expand Down

0 comments on commit 665d86b

Please sign in to comment.