1 package org.jahia.utils; 2 3 import java.util.*; 4 import java.io.Serializable ; 5 6 7 15 16 public class InsertionSortedSet extends AbstractSet implements Serializable { 17 18 private ArrayList internalSet; 19 20 public InsertionSortedSet() { 21 internalSet = new ArrayList(); 22 } 23 24 public InsertionSortedSet(Collection c) { 25 internalSet = new ArrayList(c); 26 } 27 28 protected void setInternalList (ArrayList internalList) { 29 this.internalSet = internalList; 30 } 31 32 public boolean add(Object o) 33 throws UnsupportedOperationException , 34 NullPointerException , 35 ClassCastException , 36 IllegalArgumentException { 37 if (internalSet.contains(o)) { 38 return false; 39 } else { 40 internalSet.add(o); 41 return true; 42 } 43 } 44 45 public Iterator iterator() { 46 return internalSet.iterator(); 47 } 48 49 public int size() { 50 return internalSet.size(); 51 } 52 53 } 54 | Popular Tags |