Class SegmentedArray<N extends java.lang.Comparable<N>>

    • Field Detail

      • myIndexBits

        private final int myIndexBits
      • myIndexMask

        private final long myIndexMask
      • mySegmentFactory

        private final ArrayFactory<N extends java.lang.Comparable<N>,​?> mySegmentFactory
      • mySegments

        private final BasicArray<N extends java.lang.Comparable<N>>[] mySegments
      • mySegmentSize

        private final long mySegmentSize
        All segments except the last one are assumed to (must) be of equal length. The last segment cannot be longer than the others.
    • Constructor Detail

      • SegmentedArray

        SegmentedArray​(long count,
                       int indexBits,
                       ArrayFactory<N,​?> segmentFactory)
    • Method Detail

      • add

        public void add​(long index,
                        java.lang.Comparable<?> addend)
      • add

        public void add​(long index,
                        double addend)
      • add

        public void add​(long index,
                        float addend)
      • count

        public long count()
        Description copied from interface: Structure1D
        The total number of elements in this structure.

        You only need to implement this method if the structure can contain more than Integer.MAX_VALUE elements.

      • doubleValue

        public double doubleValue​(int index)
      • doubleValue

        public double doubleValue​(long index)
      • fillAll

        public void fillAll​(N value)
      • fillRange

        public void fillRange​(long first,
                              long limit,
                              N value)
      • fillRange

        public void fillRange​(long first,
                              long limit,
                              NullaryFunction<?> supplier)
      • get

        public N get​(long index)
      • modifyOne

        public void modifyOne​(long index,
                              UnaryFunction<N> modifier)
      • reset

        public void reset()
        Description copied from interface: Mutate1D
        Reset this mutable structure to some standard (all zeros) initial state. It must still be usuable after this call, and the structure/size/shape must not change.
      • set

        public void set​(int index,
                        double value)
      • set

        public void set​(long index,
                        java.lang.Comparable<?> value)
      • set

        public void set​(long index,
                        double value)
      • set

        public void set​(long index,
                        float value)
      • size

        public int size()
        Description copied from interface: Structure1D
        The total number of elements in this structure.
      • visitOne

        public void visitOne​(long index,
                             VoidFunction<N> visitor)
      • exchange

        protected void exchange​(long firstA,
                                long firstB,
                                long step,
                                long count)
        Overrides:
        exchange in class BasicArray<N extends java.lang.Comparable<N>>
      • fill

        protected void fill​(long first,
                            long limit,
                            long step,
                            N value)
        Overrides:
        fill in class BasicArray<N extends java.lang.Comparable<N>>
      • fill

        protected void fill​(long first,
                            long limit,
                            long step,
                            NullaryFunction<?> supplier)
        Overrides:
        fill in class BasicArray<N extends java.lang.Comparable<N>>
      • modify

        protected void modify​(long first,
                              long limit,
                              long step,
                              UnaryFunction<N> function)
        Overrides:
        modify in class BasicArray<N extends java.lang.Comparable<N>>
      • visit

        protected void visit​(long first,
                             long limit,
                             long step,
                             VoidFunction<N> visitor)
        Overrides:
        visit in class BasicArray<N extends java.lang.Comparable<N>>
      • grow

        SegmentedArray<N> grow()
        Will either grow the last segment to be the same size as all the others, or add another segment (with the same size). The returned (could be the same) instance is guaranteed to have a last segement of the same size as the others and at least one more "space" in that segment.