< prev index next >

src/java.base/share/classes/java/util/JumboEnumSet.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 "jumbo" enum types
  30  * (i.e., those with more than 64 elements).
  31  *
  32  * @author Josh Bloch
  33  * @since 1.5
  34  * @serial exclude
  35  */
  36 class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {

  37     private static final long serialVersionUID = 334349849919042784L;
  38 
  39     /**
  40      * Bit vector representation of this set.  The ith bit of the jth
  41      * element of this array represents the  presence of universe[64*j +i]
  42      * in this set.
  43      */
  44     private long elements[];
  45 
  46     // Redundant - maintained for performance
  47     private int size = 0;
  48 
  49     JumboEnumSet(Class<E>elementType, Enum<?>[] universe) {
  50         super(elementType, universe);
  51         elements = new long[(universe.length + 63) >>> 6];
  52     }
  53 
  54     void addRange(E from, E to) {
  55         int fromIndex = from.ordinal() >>> 6;
  56         int toIndex = to.ordinal() >>> 6;




  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 "jumbo" enum types
  30  * (i.e., those with more than 64 elements).
  31  *
  32  * @author Josh Bloch
  33  * @since 1.5
  34  * @serial exclude
  35  */
  36 class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
  37     @java.io.Serial
  38     private static final long serialVersionUID = 334349849919042784L;
  39 
  40     /**
  41      * Bit vector representation of this set.  The ith bit of the jth
  42      * element of this array represents the  presence of universe[64*j +i]
  43      * in this set.
  44      */
  45     private long elements[];
  46 
  47     // Redundant - maintained for performance
  48     private int size = 0;
  49 
  50     JumboEnumSet(Class<E>elementType, Enum<?>[] universe) {
  51         super(elementType, universe);
  52         elements = new long[(universe.length + 63) >>> 6];
  53     }
  54 
  55     void addRange(E from, E to) {
  56         int fromIndex = from.ordinal() >>> 6;
  57         int toIndex = to.ordinal() >>> 6;


< prev index next >