IT. Expert System.

Android Reference

BitSet


java.util

Class BitSet

    • Constructor Summary

      Constructors
      Constructor and Description
      BitSet()
      Creates a new BitSet with size equal to 64 bits.
      BitSet(int bitCount)
      Creates a new BitSet with size equal to bitCount, rounded up to a multiple of 64.
    • Method Summary

      Methods
      Modifier and Type Method and Description
      void and(BitSet bs)
      Logically ands the bits of this BitSet with bs.
      void andNot(BitSet bs)
      Clears all bits in this BitSet which are also set in bs.
      int cardinality()
      Returns the number of bits that are true in this BitSet.
      void clear()
      Clears all the bits in this BitSet.
      void clear(int index)
      Clears the bit at index index.
      void clear(int fromIndex, int toIndex)
      Clears the range of bits [fromIndex, toIndex).
      Object clone()
      Creates and returns a copy of this Object.
      boolean equals(Object o)
      Compares this instance with the specified object and indicates if they are equal.
      void flip(int index)
      Flips the bit at index index.
      void flip(int fromIndex, int toIndex)
      Flips the range of bits [fromIndex, toIndex).
      boolean get(int index)
      Returns the bit at index index.
      BitSet get(int fromIndex, int toIndex)
      Returns a new BitSet containing the range of bits [fromIndex, toIndex), shifted down so that the bit at fromIndex is at bit 0 in the new BitSet.
      int hashCode()
      Returns an integer hash code for this object.
      boolean intersects(BitSet bs)
      Returns true if this.and(bs) is non-empty, but may be faster than computing that.
      boolean isEmpty()
      Returns true if all the bits in this BitSet are set to false, false otherwise.
      int length()
      Returns the number of bits up to and including the highest bit set.
      int nextClearBit(int index)
      Returns the index of the first bit that is clear on or after index.
      int nextSetBit(int index)
      Returns the index of the first bit that is set on or after index, or -1 if no higher bits are set.
      void or(BitSet bs)
      Logically ors the bits of this BitSet with bs.
      int previousClearBit(int index)
      Returns the index of the first bit that is clear on or before index, or -1 if no lower bits are clear or index == -1.
      int previousSetBit(int index)
      Returns the index of the first bit that is set on or before index, or -1 if no lower bits are set or index == -1.
      void set(int index)
      Sets the bit at index index to true.
      void set(int index, boolean state)
      Sets the bit at index index to state.
      void set(int fromIndex, int toIndex)
      Sets the range of bits [fromIndex, toIndex).
      void set(int fromIndex, int toIndex, boolean state)
      Sets the range of bits [fromIndex, toIndex) to state.
      int size()
      Returns the capacity in bits of the array implementing this BitSet.
      byte[] toByteArray()
      Returns a new byte[] containing a little-endian representation the bits of this BitSet, suitable for passing to valueOf to reconstruct this BitSet.
      long[] toLongArray()
      Returns a new long[] containing a little-endian representation of the bits of this BitSet, suitable for passing to valueOf to reconstruct this BitSet.
      String toString()
      Returns a string containing a concise, human-readable description of the receiver: a comma-delimited list of the indexes of all set bits.
      static BitSet valueOf(byte[] bytes)
      Equivalent to BitSet.valueOf(ByteBuffer.wrap(bytes)).
      static BitSet valueOf(ByteBuffer byteBuffer)
      Returns a BitSet corresponding to byteBuffer, interpreted as a little-endian sequence of bits.
      static BitSet valueOf(long[] longs)
      Equivalent to BitSet.valueOf(LongBuffer.wrap(longs)), but likely to be faster.
      static BitSet valueOf(LongBuffer longBuffer)
      Returns a BitSet corresponding to longBuffer, interpreted as a little-endian sequence of bits.
      void xor(BitSet bs)
      Logically xors the bits of this BitSet with bs.
    • Constructor Detail

      • BitSet

        public BitSet()
        Creates a new BitSet with size equal to 64 bits.
      • BitSet

        public BitSet(int bitCount)
        Creates a new BitSet with size equal to bitCount, rounded up to a multiple of 64.
        Throws:
        NegativeArraySizeException - if bitCount < 0.
    • Method Detail

      • clone

        public Object clone()
        Description copied from class: Object
        Creates and returns a copy of this Object. The default implementation returns a so-called "shallow" copy: It creates a new instance of the same class and then copies the field values (including object references) from this instance to the new instance. A "deep" copy, in contrast, would also recursively clone nested objects. A subclass that needs to implement this kind of cloning should call super.clone() to create the new instance and then create deep copies of the nested, mutable objects.
        Overrides:
        clone in class Object
        Returns:
        a copy of this object.
      • equals

        public boolean equals(Object o)
        Description copied from class: Object
        Compares this instance with the specified object and indicates if they are equal. In order to be equal, o must represent the same object as this instance using a class-specific comparison. The general contract is that this comparison should be reflexive, symmetric, and transitive. Also, no object reference other than null is equal to null.

        The default implementation returns true only if this == o. See Writing a correct equals method if you intend implementing your own equals method.

        The general contract for the equals and Object.hashCode() methods is that if equals returns true for any two objects, then hashCode() must return the same value for these objects. This means that subclasses of Object usually override either both methods or neither of them.

        Overrides:
        equals in class Object
        Parameters:
        o - the object to compare this instance with.
        Returns:
        true if the specified object is equal to this Object; false otherwise.
        See Also:
        Object.hashCode()
      • hashCode

        public int hashCode()
        Description copied from class: Object
        Returns an integer hash code for this object. By contract, any two objects for which Object.equals(java.lang.Object) returns true must return the same hash code value. This means that subclasses of Object usually override both methods or neither method.

        Note that hash values must not change over time unless information used in equals comparisons also changes.

        See Writing a correct hashCode method if you intend implementing your own hashCode method.

        Overrides:
        hashCode in class Object
        Returns:
        this object's hash code.
        See Also:
        Object.equals(java.lang.Object)
      • get

        public boolean get(int index)
        Returns the bit at index index. Indexes greater than the current length return false.
        Throws:
        IndexOutOfBoundsException - if index < 0.
      • get

        public BitSet get(int fromIndex,
                 int toIndex)
        Returns a new BitSet containing the range of bits [fromIndex, toIndex), shifted down so that the bit at fromIndex is at bit 0 in the new BitSet.
        Throws:
        IndexOutOfBoundsException - if fromIndex or toIndex is negative, or if toIndex is smaller than fromIndex.
      • set

        public void set(int index,
               boolean state)
        Sets the bit at index index to state.
        Throws:
        IndexOutOfBoundsException - if index < 0.
      • set

        public void set(int fromIndex,
               int toIndex,
               boolean state)
        Sets the range of bits [fromIndex, toIndex) to state.
        Throws:
        IndexOutOfBoundsException - if fromIndex or toIndex is negative, or if toIndex is smaller than fromIndex.
      • clear

        public void clear()
        Clears all the bits in this BitSet. This method does not change the capacity. Use clear if you want to reuse this BitSet with the same capacity, but create a new BitSet if you're trying to potentially reclaim memory.
      • set

        public void set(int fromIndex,
               int toIndex)
        Sets the range of bits [fromIndex, toIndex).
        Throws:
        IndexOutOfBoundsException - if fromIndex or toIndex is negative, or if toIndex is smaller than fromIndex.
      • clear

        public void clear(int fromIndex,
                 int toIndex)
        Clears the range of bits [fromIndex, toIndex).
        Throws:
        IndexOutOfBoundsException - if fromIndex or toIndex is negative, or if toIndex is smaller than fromIndex.
      • flip

        public void flip(int fromIndex,
                int toIndex)
        Flips the range of bits [fromIndex, toIndex).
        Throws:
        IndexOutOfBoundsException - if fromIndex or toIndex is negative, or if toIndex is smaller than fromIndex.
      • intersects

        public boolean intersects(BitSet bs)
        Returns true if this.and(bs) is non-empty, but may be faster than computing that.
      • and

        public void and(BitSet bs)
        Logically ands the bits of this BitSet with bs.
      • andNot

        public void andNot(BitSet bs)
        Clears all bits in this BitSet which are also set in bs.
      • or

        public void or(BitSet bs)
        Logically ors the bits of this BitSet with bs.
      • xor

        public void xor(BitSet bs)
        Logically xors the bits of this BitSet with bs.
      • size

        public int size()
        Returns the capacity in bits of the array implementing this BitSet. This is unrelated to the length of the BitSet, and not generally useful. Use nextSetBit(int) to iterate, or length() to find the highest set bit.
      • length

        public int length()
        Returns the number of bits up to and including the highest bit set. This is unrelated to the size() of the BitSet.
      • toString

        public String toString()
        Returns a string containing a concise, human-readable description of the receiver: a comma-delimited list of the indexes of all set bits. For example: "{0,1,8}".
        Overrides:
        toString in class Object
        Returns:
        a printable representation of this object.
      • nextSetBit

        public int nextSetBit(int index)
        Returns the index of the first bit that is set on or after index, or -1 if no higher bits are set.
        Throws:
        IndexOutOfBoundsException - if index < 0.
      • nextClearBit

        public int nextClearBit(int index)
        Returns the index of the first bit that is clear on or after index. Since all bits past the end are implicitly clear, this never returns -1.
        Throws:
        IndexOutOfBoundsException - if index < 0.
      • previousSetBit

        public int previousSetBit(int index)
        Returns the index of the first bit that is set on or before index, or -1 if no lower bits are set or index == -1.
        Throws:
        IndexOutOfBoundsException - if index < -1.
      • previousClearBit

        public int previousClearBit(int index)
        Returns the index of the first bit that is clear on or before index, or -1 if no lower bits are clear or index == -1.
        Throws:
        IndexOutOfBoundsException - if index < -1.
      • isEmpty

        public boolean isEmpty()
        Returns true if all the bits in this BitSet are set to false, false otherwise.
      • cardinality

        public int cardinality()
        Returns the number of bits that are true in this BitSet.
      • valueOf

        public static BitSet valueOf(long[] longs)
        Equivalent to BitSet.valueOf(LongBuffer.wrap(longs)), but likely to be faster. This is likely to be the fastest way to create a BitSet because it's closest to the internal representation.
      • valueOf

        public static BitSet valueOf(LongBuffer longBuffer)
        Returns a BitSet corresponding to longBuffer, interpreted as a little-endian sequence of bits. This method does not alter the LongBuffer.
      • valueOf

        public static BitSet valueOf(byte[] bytes)
        Equivalent to BitSet.valueOf(ByteBuffer.wrap(bytes)).
      • valueOf

        public static BitSet valueOf(ByteBuffer byteBuffer)
        Returns a BitSet corresponding to byteBuffer, interpreted as a little-endian sequence of bits. This method does not alter the ByteBuffer.
      • toLongArray

        public long[] toLongArray()
        Returns a new long[] containing a little-endian representation of the bits of this BitSet, suitable for passing to valueOf to reconstruct this BitSet.
      • toByteArray

        public byte[] toByteArray()
        Returns a new byte[] containing a little-endian representation the bits of this BitSet, suitable for passing to valueOf to reconstruct this BitSet.


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 1816 / . Delta: 0.03187 с