Class LongBufferWrapper

  • All Implemented Interfaces:
    Buffer, java.lang.Cloneable

    final class LongBufferWrapper
    extends java.lang.Object
    implements Buffer, java.lang.Cloneable
    java.nio.LongBuffer wrapper. Users should not be concerned by this class.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int actualSizeInWords
      The actual size in words.
      private java.nio.LongBuffer buffer
      The buffer
    • Constructor Summary

      Constructors 
      Constructor Description
      LongBufferWrapper​(java.nio.LongBuffer buffer)  
      LongBufferWrapper​(java.nio.LongBuffer slice, int sizeInWords)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void andLastWord​(long mask)
      Replaces the last word position in the buffer with its bitwise-and with the given mask.
      void andWord​(int position, long mask)
      Replaces the word at the given position in the buffer with its bitwise-and with the given mask.
      void clear()
      Resets the buffer The buffer is not fully cleared and any new set operations should overwrite stale data
      LongBufferWrapper clone()
      Creates and returns a copy of the buffer
      void collapse​(int position, int length)
      Removes a given number of words at the given position in the buffer.
      void ensureCapacity​(int capacity)
      Increases the size of the buffer if necessary
      void expand​(int position, int length)
      Expands the buffer by adding the given number of words at the given position.
      long getLastWord()
      Returns the last word of the buffer
      long getWord​(int position)
      Returns the word at a given position
      void negateWord​(int position)
      Negates the word at the given position in the buffer
      void negative_push_back​(Buffer buffer, int start, int number)
      Same as push_back, but the words are negated.
      void orLastWord​(long mask)
      Replaces the last word position in the buffer with its bitwise-or with the given mask.
      void orWord​(int position, long mask)
      Replaces the word at the given position in the buffer with its bitwise-or with the given mask.
      void push_back​(long word)
      Appends the specified word to the end of the buffer
      void push_back​(Buffer buffer, int start, int number)
      Appends the specified buffer words to the end of the buffer.
      void removeLastWord()
      Removes the last word from the buffer
      void setLastWord​(long word)
      Replaces the last word in the buffer with the specified word.
      void setWord​(int position, long word)
      Replaces the word at the given position in the buffer with the specified word.
      int sizeInWords()
      Returns the actual size in words
      void swap​(Buffer other)
      Swap the content of the buffer with another.
      void trim()
      Reduces the internal buffer to its minimal allowable size.
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • actualSizeInWords

        private int actualSizeInWords
        The actual size in words.
      • buffer

        private java.nio.LongBuffer buffer
        The buffer
    • Constructor Detail

      • LongBufferWrapper

        public LongBufferWrapper​(java.nio.LongBuffer buffer)
      • LongBufferWrapper

        public LongBufferWrapper​(java.nio.LongBuffer slice,
                                 int sizeInWords)
    • Method Detail

      • sizeInWords

        public int sizeInWords()
        Description copied from interface: Buffer
        Returns the actual size in words
        Specified by:
        sizeInWords in interface Buffer
      • ensureCapacity

        public void ensureCapacity​(int capacity)
        Description copied from interface: Buffer
        Increases the size of the buffer if necessary
        Specified by:
        ensureCapacity in interface Buffer
      • getWord

        public long getWord​(int position)
        Description copied from interface: Buffer
        Returns the word at a given position
        Specified by:
        getWord in interface Buffer
        Returns:
        the word
      • getLastWord

        public long getLastWord()
        Description copied from interface: Buffer
        Returns the last word of the buffer
        Specified by:
        getLastWord in interface Buffer
        Returns:
        the last word
      • clear

        public void clear()
        Description copied from interface: Buffer
        Resets the buffer The buffer is not fully cleared and any new set operations should overwrite stale data
        Specified by:
        clear in interface Buffer
      • trim

        public void trim()
        Description copied from interface: Buffer
        Reduces the internal buffer to its minimal allowable size. This can free memory.
        Specified by:
        trim in interface Buffer
      • setWord

        public void setWord​(int position,
                            long word)
        Description copied from interface: Buffer
        Replaces the word at the given position in the buffer with the specified word.
        Specified by:
        setWord in interface Buffer
      • setLastWord

        public void setLastWord​(long word)
        Description copied from interface: Buffer
        Replaces the last word in the buffer with the specified word.
        Specified by:
        setLastWord in interface Buffer
      • push_back

        public void push_back​(long word)
        Description copied from interface: Buffer
        Appends the specified word to the end of the buffer
        Specified by:
        push_back in interface Buffer
      • push_back

        public void push_back​(Buffer buffer,
                              int start,
                              int number)
        Description copied from interface: Buffer
        Appends the specified buffer words to the end of the buffer.
        Specified by:
        push_back in interface Buffer
        Parameters:
        buffer - the buffer
        start - the position of the first word to add
        number - the number of words to add
      • negative_push_back

        public void negative_push_back​(Buffer buffer,
                                       int start,
                                       int number)
        Description copied from interface: Buffer
        Same as push_back, but the words are negated.
        Specified by:
        negative_push_back in interface Buffer
        Parameters:
        buffer - the buffer
        start - the position of the first word to add
        number - the number of words to add
      • removeLastWord

        public void removeLastWord()
        Description copied from interface: Buffer
        Removes the last word from the buffer
        Specified by:
        removeLastWord in interface Buffer
      • negateWord

        public void negateWord​(int position)
        Description copied from interface: Buffer
        Negates the word at the given position in the buffer
        Specified by:
        negateWord in interface Buffer
      • andWord

        public void andWord​(int position,
                            long mask)
        Description copied from interface: Buffer
        Replaces the word at the given position in the buffer with its bitwise-and with the given mask.
        Specified by:
        andWord in interface Buffer
      • orWord

        public void orWord​(int position,
                           long mask)
        Description copied from interface: Buffer
        Replaces the word at the given position in the buffer with its bitwise-or with the given mask.
        Specified by:
        orWord in interface Buffer
      • andLastWord

        public void andLastWord​(long mask)
        Description copied from interface: Buffer
        Replaces the last word position in the buffer with its bitwise-and with the given mask.
        Specified by:
        andLastWord in interface Buffer
      • orLastWord

        public void orLastWord​(long mask)
        Description copied from interface: Buffer
        Replaces the last word position in the buffer with its bitwise-or with the given mask.
        Specified by:
        orLastWord in interface Buffer
      • expand

        public void expand​(int position,
                           int length)
        Description copied from interface: Buffer
        Expands the buffer by adding the given number of words at the given position. The added words may contain stale data.
        Specified by:
        expand in interface Buffer
        Parameters:
        position - the position of the buffer where to add words
        length - the number of words to add
      • collapse

        public void collapse​(int position,
                             int length)
        Description copied from interface: Buffer
        Removes a given number of words at the given position in the buffer. The freed words at the end of the buffer are properly cleaned.
        Specified by:
        collapse in interface Buffer
        Parameters:
        position - the position of the buffer where to add words
        length - the number of words to add
      • clone

        public LongBufferWrapper clone()
                                throws java.lang.CloneNotSupportedException
        Description copied from interface: Buffer
        Creates and returns a copy of the buffer
        Specified by:
        clone in interface Buffer
        Overrides:
        clone in class java.lang.Object
        Throws:
        java.lang.CloneNotSupportedException
      • swap

        public void swap​(Buffer other)
        Description copied from interface: Buffer
        Swap the content of the buffer with another.
        Specified by:
        swap in interface Buffer
        Parameters:
        other - buffer to swap with