1 29 package org.jruby.util.collections; 30 31 import java.util.ArrayList ; 32 import java.util.Collection ; 33 import java.util.Iterator ; 34 35 36 public class IdentitySet { 37 private Collection items = new ArrayList (); 38 39 public void add(Object item) { 40 items.add(item); 41 } 42 43 public void remove(Object item) { 44 Iterator iter = items.iterator(); 45 while (iter.hasNext()) { 46 Object storedItem = iter.next(); 47 if (item == storedItem) { 48 iter.remove(); 49 } 50 } 51 } 52 53 public boolean contains(Object item) { 54 Iterator iter = items.iterator(); 55 while (iter.hasNext()) { 56 Object storedItem = iter.next(); 57 if (item == storedItem) { 58 return true; 59 } 60 } 61 return false; 62 } 63 } 64 | Popular Tags |