Package boofcv.misc

Class CircularIndex

java.lang.Object
boofcv.misc.CircularIndex

public class CircularIndex
extends Object
Function for use when referencing the index in a circular list
  • Constructor Summary

    Constructors
    Constructor Description
    CircularIndex()  
  • Method Summary

    Modifier and Type Method Description
    static int addOffset​(int index, int offset, int size)
    Adds offset (positive or negative) to index in a circular buffer.
    static int distance​(int index0, int index1, int size)
    Returns the smallest distance you would need to travel (positive or negative) to go from index0 to index1.
    static int distanceP​(int index0, int index1, int size)
    Returns how many elements away in the positive direction you need to travel to get from index0 to index1.
    static int minusPOffset​(int index, int offset, int size)
    Subtracts a positive offset to index in a circular buffer.
    static int plusPOffset​(int index, int offset, int size)
    Adds a positive offset to index in a circular buffer.
    static int subtract​(int index0, int index1, int size)
    Subtracts index1 from index0.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CircularIndex

      public CircularIndex()
  • Method Details

    • plusPOffset

      public static int plusPOffset​(int index, int offset, int size)
      Adds a positive offset to index in a circular buffer.
      Parameters:
      index - element in circular buffer
      offset - integer which is positive and less than size
      size - size of the circular buffer
      Returns:
      new index
    • minusPOffset

      public static int minusPOffset​(int index, int offset, int size)
      Subtracts a positive offset to index in a circular buffer.
      Parameters:
      index - element in circular buffer
      offset - integer which is positive and less than size
      size - size of the circular buffer
      Returns:
      new index
    • addOffset

      public static int addOffset​(int index, int offset, int size)
      Adds offset (positive or negative) to index in a circular buffer.
      Parameters:
      index - element in circular buffer
      offset - offset. |offset| < size
      size - size of the circular buffer
      Returns:
      new index
    • distanceP

      public static int distanceP​(int index0, int index1, int size)
      Returns how many elements away in the positive direction you need to travel to get from index0 to index1.
      Parameters:
      index0 - element in circular buffer
      index1 - element in circular buffer
      size - size of the circular buffer
      Returns:
      positive distance
    • distance

      public static int distance​(int index0, int index1, int size)
      Returns the smallest distance you would need to travel (positive or negative) to go from index0 to index1.
      Parameters:
      index0 - element in circular buffer
      index1 - element in circular buffer
      size - size of the circular buffer
      Returns:
      smallest distance
    • subtract

      public static int subtract​(int index0, int index1, int size)
      Subtracts index1 from index0. positive number if its closer in the positive direction or negative if closer in the negative direction. if equal distance then it will return a negative number.
      Parameters:
      index0 - element in circular buffer
      index1 - element in circular buffer
      size - size of the circular buffer
      Returns:
      new index