< prev index next >

src/java.base/share/classes/java/util/RegularEnumSet.java

Print this page




  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package java.util;
  27 
  28 /**
  29  * Private implementation class for EnumSet, for "regular sized" enum types
  30  * (i.e., those with 64 or fewer enum constants).
  31  *
  32  * @author Josh Bloch
  33  * @since 1.5
  34  * @serial exclude
  35  */
  36 class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {

  37     private static final long serialVersionUID = 3411599620347842686L;
  38     /**
  39      * Bit vector representation of this set.  The 2^k bit indicates the
  40      * presence of universe[k] in this set.
  41      */
  42     private long elements = 0L;
  43 
  44     RegularEnumSet(Class<E>elementType, Enum<?>[] universe) {
  45         super(elementType, universe);
  46     }
  47 
  48     void addRange(E from, E to) {
  49         elements = (-1L >>>  (from.ordinal() - to.ordinal() - 1)) << from.ordinal();
  50     }
  51 
  52     void addAll() {
  53         if (universe.length != 0)
  54             elements = -1L >>> -universe.length;
  55     }
  56 




  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package java.util;
  27 
  28 /**
  29  * Private implementation class for EnumSet, for "regular sized" enum types
  30  * (i.e., those with 64 or fewer enum constants).
  31  *
  32  * @author Josh Bloch
  33  * @since 1.5
  34  * @serial exclude
  35  */
  36 class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {
  37     @java.io.Serial
  38     private static final long serialVersionUID = 3411599620347842686L;
  39     /**
  40      * Bit vector representation of this set.  The 2^k bit indicates the
  41      * presence of universe[k] in this set.
  42      */
  43     private long elements = 0L;
  44 
  45     RegularEnumSet(Class<E>elementType, Enum<?>[] universe) {
  46         super(elementType, universe);
  47     }
  48 
  49     void addRange(E from, E to) {
  50         elements = (-1L >>>  (from.ordinal() - to.ordinal() - 1)) << from.ordinal();
  51     }
  52 
  53     void addAll() {
  54         if (universe.length != 0)
  55             elements = -1L >>> -universe.length;
  56     }
  57 


< prev index next >