パッケージ org.piax.common.subspace

クラス Range<K extends Comparable<?>>

java.lang.Object
org.piax.common.subspace.Range<K>
型パラメータ:
K - the type of minimum and maximum keys of the range
すべての実装されたインタフェース:
Serializable, Cloneable
直系の既知のサブクラス:
KeyRange

public class Range<K extends Comparable<?>>
extends Object
implements Serializable, Cloneable
a class that represents a single range.
関連項目:
直列化された形式
  • フィールドの概要

    フィールド 
    修飾子とタイプ フィールド 説明
    K from  
    boolean fromInclusive  
    protected static KeyComparator keyComp  
    K to  
    boolean toInclusive  
  • コンストラクタの概要

    コンストラクタ 
    コンストラクタ 説明
    Range​(boolean allowCircular, K from, boolean fromInclusive, K to, boolean toInclusive)
    construct a range.
    Range​(char fromEdgeSpec, K from, K to, char toEdgeSpec)
    constructor to allow the form like Range('[', 10, 20, ')');
    Range​(K key)
    construct [key, key]
    Range​(K from, boolean fromInclusive, K to, boolean toInclusive)
    construct a range
    Range​(K from, K to)
    construct a non-circular range [from, to]
  • メソッドの概要

    修飾子とタイプ メソッド 説明
    Range<K> clone()  
    boolean contains​(Comparable<?> key)
    returns true if a key is within this range.
    boolean contains​(Range<K> another)
    check if another range ⊆ this range.
    boolean equals​(Object obj)  
    int hashCode()  
    boolean hasIntersection​(Range<K> another)
    returns if another range intersects this range.
    boolean isFollowedBy​(Range<K> another)
    returns if this range is immediately followed by another range.
    boolean isSameRange​(Range<K> another)  
    boolean isSingleton()
    returns whether the range represents [x, x].
    boolean isWhole()
    returns whether the range represents [x, x).
    <T extends Range<K>>
    T
    newRange​(K from, boolean fromInclusive, K to, boolean toInclusive)
    create a new range.
    Range<K> newRange​(Range<K> another)  
    String rangeString()  
    <T extends Range<K>>
    List<T>
    retain​(Range<K> r, List<T> intersect)
    returns remaining range(s) when subtracting a specified range from this range.
    <T extends Range<K>>
    List<T>
    split​(K k)
    split the range with given k.
    String toString()  
    String toString2()  

    クラスから継承されたメソッド java.lang.Object

    finalize, getClass, notify, notifyAll, wait, wait, wait
  • フィールド詳細

  • コンストラクタの詳細

    • Range

      public Range​(K from, K to)
      construct a non-circular range [from, to]
      パラメータ:
      from - the minimum key (inclusive)
      to - the maximum key (inclusive)
    • Range

      public Range​(K key)
      construct [key, key]
      パラメータ:
      key - the minimum and maximum key
    • Range

      public Range​(K from, boolean fromInclusive, K to, boolean toInclusive)
      construct a range
      パラメータ:
      from - the minimum key
      fromInclusive - true if from is inclusive
      to - the maximum key
      toInclusive - true if to is inclusive
    • Range

      public Range​(boolean allowCircular, K from, boolean fromInclusive, K to, boolean toInclusive)
      construct a range. this constructor allows circular ranges such as [1, 0).
      パラメータ:
      allowCircular - true if circular range is allowed
      from - the minimum key
      fromInclusive - true if from is inclusive
      to - the maximum key
      toInclusive - true if to is inclusive
    • Range

      public Range​(char fromEdgeSpec, K from, K to, char toEdgeSpec)
      constructor to allow the form like Range('[', 10, 20, ')');
      パラメータ:
      fromEdgeSpec - the lower-side edge specifier of range
      from - lower value of the range.
      to - upper value of the range.
      toEdgeSpec - the upper-side edge specifier of range
  • メソッドの詳細

    • isSingleton

      public boolean isSingleton()
      returns whether the range represents [x, x].
      戻り値:
      true if the range represents [x, x].
    • isWhole

      public boolean isWhole()
      returns whether the range represents [x, x).
      戻り値:
      true if the range represents [x, x).
    • contains

      public boolean contains​(Comparable<?> key)
      returns true if a key is within this range.
      パラメータ:
      key - the key to compare with
      戻り値:
      true if the key is within this range.
    • contains

      public boolean contains​(Range<K> another)
      check if another range ⊆ this range.
      パラメータ:
      another - another range
      戻り値:
      true if this range contains another.
    • toString

      public String toString()
      オーバーライド:
      toString クラス内 Object
    • toString2

      public String toString2()
    • rangeString

      public String rangeString()
    • isSameRange

      public boolean isSameRange​(Range<K> another)
    • hashCode

      public int hashCode()
      オーバーライド:
      hashCode クラス内 Object
    • equals

      public boolean equals​(Object obj)
      オーバーライド:
      equals クラス内 Object
    • split

      public <T extends Range<K>> List<T> split​(K k)
      split the range with given k. if k is included in the range, the results is {#min, k), [k, max#}. otherwise, the results is {#min, max#}. #min is either '(' or '[' and max# is either ')' or ']', depending on the openness of this range.
      型パラメータ:
      T - type of the Range class
      パラメータ:
      k - the key to split
      戻り値:
      the split ranges
    • clone

      public Range<K> clone()
      オーバーライド:
      clone クラス内 Object
    • newRange

      public <T extends Range<K>> T newRange​(K from, boolean fromInclusive, K to, boolean toInclusive)
      create a new range.

      this method is used for creating ranges by methods such as retain().

      subclasses must override this method to create an instance of the same class.

      型パラメータ:
      T - the actual type of Range
      パラメータ:
      from - the minimum key
      fromInclusive - true if from is inclusive
      to - the maximum key
      toInclusive - true if to is inclusive
      戻り値:
      new Range instance
    • newRange

      public Range<K> newRange​(Range<K> another)
    • retain

      public <T extends Range<K>> List<T> retain​(Range<K> r, List<T> intersect)
      returns remaining range(s) when subtracting a specified range from this range. the subtracted range(s) (intersected range) are added to `intersect' if `intersect' is not null. このクラスのサブクラス X から呼び出す場合,返り値の型は List<X> である.
       example:
         this:     [==========]
         r:           [===]
         returned: [==)   (===]
      
         this:     [==========]
         r:                 [===]
         returned: [========)
      
       
      型パラメータ:
      T - the type of range class
      パラメータ:
      r - range to subtract
      intersect - the list to add ranges that intersects with r
      戻り値:
      a list of retained ranges, possibly empty.
    • hasIntersection

      public boolean hasIntersection​(Range<K> another)
      returns if another range intersects this range.
      パラメータ:
      another - another range
      戻り値:
      true if another range intersects this range.
    • isFollowedBy

      public boolean isFollowedBy​(Range<K> another)
      returns if this range is immediately followed by another range.
      パラメータ:
      another - another range
      戻り値:
      true if this range is immediately followed by another range.