Class AttributeStreamBase

    • Constructor Detail

      • AttributeStreamBase

        public AttributeStreamBase()
    • Method Detail

      • virtualSize

        public abstract int virtualSize()
        Returns the number of elements in the stream.
      • estimateMemorySize

        public abstract long estimateMemorySize()
        Returns an estimate of this object size in bytes.
        Returns:
        Returns an estimate of this object size in bytes.
      • getPersistence

        public abstract int getPersistence()
        Returns the Persistence type of the stream.
      • readAsDbl

        public abstract double readAsDbl​(int offset)
        Reads given element and returns it as double.
      • writeAsDbl

        public abstract void writeAsDbl​(int offset,
                                        double d)
        Writes given element as double. The double is cast to the internal representation (truncated when int).
      • readAsInt

        public abstract int readAsInt​(int offset)
        Reads given element and returns it as int (truncated if double).
      • writeAsInt

        public abstract void writeAsInt​(int offset,
                                        int d)
        Writes given element as int. The int is cast to the internal representation.
      • readAsInt64

        public abstract long readAsInt64​(int offset)
        Reads given element and returns it as int (truncated if double).
      • writeAsInt64

        public abstract void writeAsInt64​(int offset,
                                          long d)
        Writes given element as int. The int is cast to the internal representation.
      • resize

        public abstract void resize​(int newSize,
                                    double defaultValue)
        Resizes the AttributeStream to the new size.
      • resize

        public abstract void resize​(int newSize)
        Resizes the AttributeStream to the new size.
      • resizePreserveCapacity

        public abstract void resizePreserveCapacity​(int newSize)
        Resizes the AttributeStream to the new size. Does not change the capacity of the stream.
      • addRange

        public abstract void addRange​(AttributeStreamBase src,
                                      int srcStart,
                                      int count,
                                      boolean bForward,
                                      int stride)
        Adds a range of elements from the source stream. The streams must be of the same type.
        Parameters:
        src - The source stream to read elements from.
        srcStart - The index of the element in the source stream to start reading from.
        count - The number of elements to add.
        bForward - True if adding the elements in order of the incoming source stream. False if adding the elements in reverse.
        stride - The number of elements to be grouped together if adding the elements in reverse.
      • insertRange

        public abstract void insertRange​(int start,
                                         AttributeStreamBase src,
                                         int srcStart,
                                         int count,
                                         boolean bForward,
                                         int stride,
                                         int validSize)
        Inserts a range of elements from the source stream. The streams must be of the same type.
        Parameters:
        start - The index where to start the insert.
        src - The source stream to read elements from.
        srcStart - The index of the element in the source stream to start reading from.
        count - The number of elements to read from the source stream.
        validSize - The number of valid elements in this stream.
      • insertRange

        public abstract void insertRange​(int start,
                                         double value,
                                         int count,
                                         int validSize)
        Inserts a range of elements of the given value.
        Parameters:
        start - The index where to start the insert.
        value - The value to be inserted.
        count - The number of elements to be inserted.
        validSize - The number of valid elements in this stream.
      • insertAttributes

        public abstract void insertAttributes​(int before,
                                              Point pt,
                                              int semantics,
                                              int validSize)
        Inserts the attributes of a given semantics from a Point geometry.
        Parameters:
        before - The index where to start the insert.
        pt - The Point geometry holding the attributes to be inserted.
        semantics - The attribute semantics that are being inserted.
        validSize - The number of valid elements in this stream.
      • insertAttributes

        public abstract void insertAttributes​(int before,
                                              Point[] src,
                                              int count,
                                              int semantics,
                                              int validSize)
      • setRange

        public abstract void setRange​(double value,
                                      int start,
                                      int count)
        Sets a range of values to given value.
        Parameters:
        value - The value to set stream elements to.
        start - The index of the element to start writing to.
        count - The number of elements to set.
      • writeRange

        public abstract void writeRange​(int startElement,
                                        int count,
                                        AttributeStreamBase src,
                                        int sourceStart,
                                        boolean bForward,
                                        int stride)
        Adds a range of elements from the source byte buffer. This stream is resized automatically to accomodate required number of elements.
        Parameters:
        startElement - the index of the element in this stream to start setting elements from.
        count - The number of AttributeStream elements to read.
        src - The source ByteBuffer to read elements from.
        sourceStart - The offset from the start of the ByteBuffer in bytes.
        bForward - When False, the source is written in reversed order.
        stride - Used for reversed writing only to indicate the unit of writing. elements inside a stride are not reversed. Only the strides are reversed.
      • writeRange

        public abstract void writeRange​(int startElement,
                                        int count,
                                        ByteBuffer src,
                                        int offsetBytes,
                                        boolean bForward)
        Adds a range of elements from the source byte buffer. The stream is resized automatically to accomodate required number of elements.
        Parameters:
        startElement - the index of the element in this stream to start setting elements from.
        count - The number of AttributeStream elements to read.
        src - The source ByteBuffer to read elements from.
        offsetBytes - The offset from the start of the ByteBuffer in bytes.
      • readRange

        public abstract void readRange​(int srcStart,
                                       int count,
                                       ByteBuffer dst,
                                       int dstOffsetBytes,
                                       boolean bForward)
        Write a range of elements to the source byte buffer.
        Parameters:
        srcStart - The element index to start writing from.
        count - The number of AttributeStream elements to write.
        dst - The destination ByteBuffer. The buffer must be large enough or it will throw.
        dstOffsetBytes - The offset in the destination ByteBuffer to start write elements from.
      • eraseRange

        public abstract void eraseRange​(int index,
                                        int count,
                                        int validSize)
        Erases a range from the buffer and defragments the result.
        Parameters:
        index - The index in this stream where the erasing starts.
        count - The number of elements to be erased.
        validSize - The number of valid elements in this stream.
      • reverseRange

        public abstract void reverseRange​(int index,
                                          int count,
                                          int stride)
        Reverses a range from the buffer.
        Parameters:
        index - The index in this stream where the reversing starts.
        count - The number of elements to be reversed.
        stride - The number of elements to be grouped together when doing the reverse.
      • rotate

        public void rotate​(int start,
                           int middle,
                           int end)
      • createByteStream

        public static AttributeStreamBase createByteStream​(int size)
        Creates a new attribute stream for storing bytes.
        Parameters:
        size - The number of elements in the stream.
      • createByteStream

        public static AttributeStreamBase createByteStream​(int size,
                                                           byte defaultValue)
        Creates a new attribute stream for storing bytes.
        Parameters:
        size - The number of elements in the stream.
        defaultValue - The default value to fill the stream with.
      • createDoubleStream

        public static AttributeStreamBase createDoubleStream​(int size)
        Creates a new attribute stream for storing doubles.
        Parameters:
        size - The number of elements in the stream.
      • createDoubleStream

        public static AttributeStreamBase createDoubleStream​(int size,
                                                             double defaultValue)
        Creates a new attribute stream for storing doubles.
        Parameters:
        size - The number of elements in the stream.
        defaultValue - The default value to fill the stream with.
      • restrictedClone

        public abstract AttributeStreamBase restrictedClone​(int maxsize)
        Creats a copy of the stream that contains upto maxsize elements.
      • createAttributeStreamWithPersistence

        public static AttributeStreamBase createAttributeStreamWithPersistence​(int persistence,
                                                                               int size)
        Creates a new attribute stream of given persistence type and size.
        Parameters:
        persistence - The persistence type of the stream (see VertexDescription).
        size - The number of elements (floats, doubles, or 32 bit integers) of the given type in the stream.
      • createAttributeStreamWithPersistence

        public static AttributeStreamBase createAttributeStreamWithPersistence​(int persistence,
                                                                               int size,
                                                                               double defaultValue)
        Creates a new attribute stream of given persistence type and size.
        Parameters:
        persistence - The persistence type of the stream (see VertexDescription).
        size - The number of elements (floats, doubles, or 32 bit integers) of the given type in the stream.
        defaultValue - The default value to fill the stream with.
      • createAttributeStreamWithSemantics

        public static AttributeStreamBase createAttributeStreamWithSemantics​(int semantics,
                                                                             int vertexCount)
        Creates a new attribute stream for the given semantics and vertex count.
        Parameters:
        semantics - The semantics of the attribute (see VertexDescription).
        vertexCount - The number of vertices in the geometry. The actual number of elements in the stream is vertexCount * ncomponents.
      • createAttributeStreamWithSemanticsUninitialized

        public static AttributeStreamBase createAttributeStreamWithSemanticsUninitialized​(int semantics,
                                                                                          int vertexCount)
      • createIndexStream

        public static AttributeStreamBase createIndexStream​(int size)
        Creates a new attribute stream for storing vertex indices.
        Parameters:
        size - The number of elements in the stream.
      • createIndexStream

        public static AttributeStreamBase createIndexStream​(int size,
                                                            int defaultValue)
        Creates a new attribute stream for storing vertex indices.
        Parameters:
        size - The number of elements in the stream.
        defaultValue - The default value to fill the stream with.
      • calculateHashImpl

        public abstract int calculateHashImpl​(int hashCode,
                                              int start,
                                              int end)
      • equals

        public abstract boolean equals​(AttributeStreamBase other,
                                       int start,
                                       int end,
                                       double tolerance)
      • growBy25

        protected static int growBy25​(int sz)
      • growSize

        protected static int growSize​(int sz)