Class CIMElementSorter

  • All Implemented Interfaces:
    java.util.Comparator<java.lang.Object>

    public class CIMElementSorter
    extends java.lang.Object
    implements java.util.Comparator<java.lang.Object>
    Class CIMElementSorter can sort CIMElement arrays and can do binary search by name in them.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compare​(java.lang.Object pObj0, java.lang.Object pObj1)  
      static CIMElement find​(CIMElement[] pArray, java.lang.String pName)
      Finds CIMElement, named pName, in pArray which must be a sorted array of CIMElements.
      static int findIdx​(CIMElement[] pArray, java.lang.String pName)
      Finds the index of CIMElement, named pName, in pArray which must be a sorted array of CIMElements.
      static CIMElement[] sort​(CIMElement[] pArray)
      Sorts the passed CIMElement array, the passed array is not copied.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Comparator

        equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
    • Constructor Detail

      • CIMElementSorter

        public CIMElementSorter()
    • Method Detail

      • sort

        public static CIMElement[] sort​(CIMElement[] pArray)
        Sorts the passed CIMElement array, the passed array is not copied.
        Parameters:
        pArray - the array which will be sorted if it's not null
        Returns:
        pArray
      • find

        public static CIMElement find​(CIMElement[] pArray,
                                      java.lang.String pName)
        Finds CIMElement, named pName, in pArray which must be a sorted array of CIMElements.
        Parameters:
        pArray -
        pName -
        Returns:
        the CIMElement if found, otherwise null
      • findIdx

        public static int findIdx​(CIMElement[] pArray,
                                  java.lang.String pName)
        Finds the index of CIMElement, named pName, in pArray which must be a sorted array of CIMElements.
        Parameters:
        pArray -
        pName -
        Returns:
        the index, just like in case of Arrays.binarySearch()
        See Also:
        Arrays.binarySearch(Object[], Object, Comparator)
      • compare

        public int compare​(java.lang.Object pObj0,
                           java.lang.Object pObj1)
        Specified by:
        compare in interface java.util.Comparator<java.lang.Object>
        See Also:
        Comparator.compare(Object, Object)