Package xal.tools

Class RealNumericIndexer<T>

java.lang.Object
xal.tools.RealNumericIndexer<T>
All Implemented Interfaces:
Iterable<T>

public class RealNumericIndexer<T> extends Object implements Iterable<T>
Order objects by their specified numeric index and assign a corresponding integer index based on sequential order and provide mapping between the two indices.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final List<xal.tools.NumericRecord<T>>
    records of data
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(double location, T value)
    Add the specified value at the specified location.
    double
    findIndex(double location)
    Get the index of the specified location.
    get(int index)
    Get the element at the specified index
    int
    getClosestIndex(double location)
    Get the index which is closest to the index of the specified location and round down if two are equally close.
    int[]
    getIndicesWithinLocationRange(double startLocation, double endLocation)
    Get the smallest range of indices whose location range contains the specified range inclusive.
    double
    getLocation(int index)
    Get the location corresponding to the specified index.
    int
    getLowerIndex(double location)
    Get the index which is the greatest integer less than or equal to the index of the specified location.
    int
    getUpperIndex(double location)
    Get the index which is the least integer greater than or equal to the index of the specified location but the greatest of equals.
    Get an indexer for the indexed items.
    remove(int index)
    Remove the specified item by index.
    int
    Get the size
    Generate a list of the values.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Field Details

    • numericRecords

      protected final List<xal.tools.NumericRecord<T>> numericRecords
      records of data
  • Constructor Details

    • RealNumericIndexer

      public RealNumericIndexer()
      Constructor
  • Method Details

    • size

      public int size()
      Get the size
      Returns:
      the number of items indexed
    • iterator

      public Iterator<T> iterator()
      Get an indexer for the indexed items.
      Specified by:
      iterator in interface Iterable<T>
      Returns:
      an iterator over the indexed items
    • toList

      public List<T> toList()
      Generate a list of the values.
      Returns:
      a list of the values ordered according to the index
    • get

      public T get(int index)
      Get the element at the specified index
      Returns:
      the value at the specified index
    • getLocation

      public double getLocation(int index)
      Get the location corresponding to the specified index.
      Parameters:
      index - the index of the record to fetch
      Returns:
      the location corresponding to the specified index
    • getLowerIndex

      public int getLowerIndex(double location)
      Get the index which is the greatest integer less than or equal to the index of the specified location. However, if there are several indices for the specified location, pick the least one.
      Parameters:
      location - the location for which to identify the array index
      Returns:
      the index which is the greatest integer less than or equal to the index of the specified location
    • getUpperIndex

      public int getUpperIndex(double location)
      Get the index which is the least integer greater than or equal to the index of the specified location but the greatest of equals. However, if there are several indices for the specified location, pick the greatest one.
      Parameters:
      location - the location for which to identify the array index
      Returns:
      the index which is the least integer greater than or equal to the index of the specified location
    • getIndicesWithinLocationRange

      public int[] getIndicesWithinLocationRange(double startLocation, double endLocation)
      Get the smallest range of indices whose location range contains the specified range inclusive.
      Parameters:
      startLocation - the starting location
      endLocation - the ending location
      Returns:
      the indices corresponding to the location range or a range of -1s if none exists
    • getClosestIndex

      public int getClosestIndex(double location)
      Get the index which is closest to the index of the specified location and round down if two are equally close.
      Parameters:
      location - the location for which to identify the array index
      Returns:
      the closest index
    • findIndex

      public double findIndex(double location)
      Get the index of the specified location.
      Parameters:
      location - the location for which to identify the array index
      Returns:
      the array index for the specified location
    • add

      public void add(double location, T value)
      Add the specified value at the specified location.
      Parameters:
      value - the value to add
      location - the location of the value
    • remove

      public T remove(int index)
      Remove the specified item by index.
      Parameters:
      index - the index of the item to remove