Package boofcv.misc
Class CircularIndex
java.lang.Object
boofcv.misc.CircularIndex
Function for use when referencing the index in a circular list
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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.
-
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 bufferoffset
- integer which is positive and less than sizesize
- 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 bufferoffset
- integer which is positive and less than sizesize
- 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 bufferoffset
- offset. |offset| < sizesize
- 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 bufferindex1
- element in circular buffersize
- 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 bufferindex1
- element in circular buffersize
- 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 bufferindex1
- element in circular buffersize
- size of the circular buffer- Returns:
- new index
-