/[classpath]/classpath/java/util/EnumSet.java
ViewVC logotype

Diff of /classpath/java/util/EnumSet.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1.2.2 by gnu_andrew, Fri Jan 7 03:42:30 2005 UTC revision 1.1.2.3 by tromey, Wed Jan 12 01:12:48 2005 UTC
# Line 61  public class EnumSet<T extends Enum<T>> Line 61  public class EnumSet<T extends Enum<T>>
61    
62    public EnumSet<T> clone()    public EnumSet<T> clone()
63    {    {
64      EnumSet<T> r = super.clone();          try
65      r.store = store.clone();            {
66      return r;                  EnumSet<T> r = (EnumSet<T>) super.clone();
67                    r.store = (BitSet) store.clone();
68                    return r;
69              }
70            catch (CloneNotSupportedException _)
71              {
72                    // Can't happen.
73                    return null;
74              }
75    }    }
76    
77    public int size()    public int size()
# Line 113  public class EnumSet<T extends Enum<T>> Line 121  public class EnumSet<T extends Enum<T>>
121    public boolean addAll(Collection<? extends T> c)    public boolean addAll(Collection<? extends T> c)
122    {    {
123      boolean result = false;      boolean result = false;
124      if (c instanceof EnumSet<T>)      if (c instanceof EnumSet)
125        {        {
126          EnumSet<T> other = (EnumSet<T>) c;          EnumSet<T> other = (EnumSet<T>) c;
127          if (enumClass == other.enumClass)          if (enumClass == other.enumClass)
# Line 143  public class EnumSet<T extends Enum<T>> Line 151  public class EnumSet<T extends Enum<T>>
151    
152    public boolean contains(Object o)    public boolean contains(Object o)
153    {    {
154      if (! (o instanceof Enum<T>))      if (! (o instanceof Enum))
155        return false;        return false;
156      Enum<T> e = (Enum<T>) o;      Enum<T> e = (Enum<T>) o;
157      if (e.getDeclaringClass() != enumClass)      if (e.getDeclaringClass() != enumClass)
# Line 153  public class EnumSet<T extends Enum<T>> Line 161  public class EnumSet<T extends Enum<T>>
161    
162    public boolean containsAll(Collection<?> c)    public boolean containsAll(Collection<?> c)
163    {    {
164      if (c instanceof EnumSet<T>)      if (c instanceof EnumSet)
165        {        {
166          EnumSet<T> other = (EnumSet<T>) c;          EnumSet<T> other = (EnumSet<T>) c;
167          if (enumClass == other.enumClass)          if (enumClass == other.enumClass)
# Line 165  public class EnumSet<T extends Enum<T>> Line 173  public class EnumSet<T extends Enum<T>>
173    
174    public boolean remove(Object o)    public boolean remove(Object o)
175    {    {
176      if (! (o instanceof Enum<T>))      if (! (o instanceof Enum))
177        return false;        return false;
178      Enum<T> e = (Enum<T>) o;      Enum<T> e = (Enum<T>) o;
179      if (e.getDeclaringClass() != enumClass)      if (e.getDeclaringClass() != enumClass)
# Line 177  public class EnumSet<T extends Enum<T>> Line 185  public class EnumSet<T extends Enum<T>>
185    
186    public boolean removeAll(Collection<?> c)    public boolean removeAll(Collection<?> c)
187    {    {
188      if (c instanceof EnumSet<T>)      if (c instanceof EnumSet)
189        {        {
190          EnumSet<T> other = (EnumSet<T>) c;          EnumSet<T> other = (EnumSet<T>) c;
191          if (enumClass != other.enumClass)          if (enumClass != other.enumClass)
# Line 192  public class EnumSet<T extends Enum<T>> Line 200  public class EnumSet<T extends Enum<T>>
200    
201    public boolean retainAll(Collection<?> c)    public boolean retainAll(Collection<?> c)
202    {    {
203      if (c instanceof EnumSet<T>)      if (c instanceof EnumSet)
204        {        {
205          EnumSet<T> other = (EnumSet<T>) c;          EnumSet<T> other = (EnumSet<T>) c;
206          if (enumClass != other.enumClass)          if (enumClass != other.enumClass)
# Line 228  public class EnumSet<T extends Enum<T>> Line 236  public class EnumSet<T extends Enum<T>>
236      // We can't just use `other.clone' since we don't want to make a      // We can't just use `other.clone' since we don't want to make a
237      // subclass.      // subclass.
238      EnumSet<T> r = new EnumSet<T>();      EnumSet<T> r = new EnumSet<T>();
239      r.store = other.store.clone();      r.store = (BitSet) other.store.clone();
240      r.cardinality = other.cardinality;      r.cardinality = other.cardinality;
241      r.enumClass = other.enumClass;      r.enumClass = other.enumClass;
242      return r;      return r;
# Line 236  public class EnumSet<T extends Enum<T>> Line 244  public class EnumSet<T extends Enum<T>>
244    
245    public static <T extends Enum<T>> EnumSet<T> copyOf(Collection<T> other)    public static <T extends Enum<T>> EnumSet<T> copyOf(Collection<T> other)
246    {    {
247      if (other instanceof EnumSet<T>)      if (other instanceof EnumSet)
248        return copyOf((EnumSet<T>) other);        return copyOf((EnumSet<T>) other);
249      EnumSet<T> r = new EnumSet<T>();      EnumSet<T> r = new EnumSet<T>();
250      for (T val : other)      for (T val : other)
# Line 258  public class EnumSet<T extends Enum<T>> Line 266  public class EnumSet<T extends Enum<T>>
266    public static <T extends Enum<T>> EnumSet<T> complementOf(EnumSet<T> other)    public static <T extends Enum<T>> EnumSet<T> complementOf(EnumSet<T> other)
267    {    {
268      EnumSet<T> r = new EnumSet<T>();      EnumSet<T> r = new EnumSet<T>();
269      r.store = other.store.clone();      r.store = (BitSet) other.store.clone();
270      r.store.flip(0, r.store.size());      r.store.flip(0, r.store.size());
271      r.cardinality = r.store.size() - other.cardinality;      r.cardinality = r.store.size() - other.cardinality;
272      r.enumClass = other.enumClass;      r.enumClass = other.enumClass;

Legend:
Removed from v.1.1.2.2  
changed lines
  Added in v.1.1.2.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26