KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > modfact > jmi > xmi > DistinctList


1 package org.objectweb.modfact.jmi.xmi;
2
3 import java.util.*;
4
5 public class DistinctList extends Vector implements java.io.Serializable JavaDoc {
6     
7     public DistinctList() {
8         super();
9     }
10     
11     public DistinctList(Collection c) {
12         super(c);
13     }
14     
15     public boolean add(Object JavaDoc o) {
16         if(this.contains(o)) return false;
17         return super.add(o);
18     }
19     
20     public boolean addAll(Collection c) {
21          Iterator it = c.iterator();
22          boolean r = false;
23          while(it.hasNext()) {
24             Object JavaDoc o = it.next();
25             if(!contains(o)) {
26                 super.add(o);
27                 r = true;
28             }
29          }
30          return r;
31     }
32     
33 }
34
Popular Tags