Exemplo n.º 1
0
  /**
   * Returns <tt>true</tt> if this set contains all of the elements in the specified collection.
   *
   * @param c collection to be checked for containment in this set
   * @return <tt>true</tt> if this set contains all of the elements in the specified collection
   * @throws NullPointerException if the specified collection is null
   */
  public boolean containsAll(Collection<?> c) {
    if (!(c instanceof JumboEnumSet)) return super.containsAll(c);

    JumboEnumSet es = (JumboEnumSet) c;
    if (es.elementType != elementType) return es.isEmpty();

    for (int i = 0; i < elements.length; i++)
      if ((es.elements[i] & ~elements[i]) != 0) return false;
    return true;
  }
Exemplo n.º 2
0
  /**
   * Adds all of the elements in the specified collection to this set.
   *
   * @param c collection whose elements are to be added to this set
   * @return <tt>true</tt> if this set changed as a result of the call
   * @throws NullPointerException if the specified collection or any of its elements are null
   */
  public boolean addAll(Collection<? extends E> c) {
    if (!(c instanceof JumboEnumSet)) return super.addAll(c);

    JumboEnumSet es = (JumboEnumSet) c;
    if (es.elementType != elementType) {
      if (es.isEmpty()) return false;
      else throw new ClassCastException(es.elementType + " != " + elementType);
    }

    for (int i = 0; i < elements.length; i++) elements[i] |= es.elements[i];
    return recalculateSize();
  }
Exemplo n.º 3
0
 public EnumSetEx<E> clone() {
   JumboEnumSet<E> result = (JumboEnumSet<E>) super.clone();
   result.elements = result.elements.clone();
   return result;
 }