KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > utils > InsertionSortedSet


1 package org.jahia.utils;
2
3 import java.util.*;
4 import java.io.Serializable JavaDoc;
5
6
7 /**
8  * <p>Title: Implementation of a set that is ordered by insertion order</p>
9  * <p>Description: </p>
10  * <p>Copyright: Copyright (c) 2002</p>
11  * <p>Company: Jahia Ltd</p>
12  * @author Serge Huber
13  * @version 1.0
14  */

15
16 public class InsertionSortedSet extends AbstractSet implements Serializable JavaDoc {
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 JavaDoc o)
33         throws UnsupportedOperationException JavaDoc,
34         NullPointerException JavaDoc,
35         ClassCastException JavaDoc,
36         IllegalArgumentException JavaDoc {
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