org.apache.directory.mavibot.btree

## Class TupleComparator<K,V>

- java.lang.Object
- - org.apache.directory.mavibot.btree.TupleComparator<K,V>

- All Implemented Interfaces:
    Comparator<Tuple<K,V>>

      public class TupleComparator<K,V>
      extends Object
      implements Comparator<Tuple<K,V>>

  An comparator that encapsulate a Comparator to compare two tuples using their key.
  Author:
    Apache Directory Project

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `TupleComparator(Comparator<K> keyComparator, Comparator<V> valueComparator)` Creates a new instance of TupleComparator.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `compare(Tuple<K,V> t1, Tuple<K,V> t2)` Compare two tuples.

    - ### 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`

- - ### Constructor Detail

    - #### TupleComparator

          public TupleComparator(Comparator<K> keyComparator,
                         Comparator<V> valueComparator)

      Creates a new instance of TupleComparator.
      Parameters:
        `keyComparator` - The inner key comparator
        `valueComparator` - The inner value comparator

  - ### Method Detail

    - #### compare

          public int compare(Tuple<K,V> t1,
                    Tuple<K,V> t2)

      Compare two tuples. We compare the keys only.
      Specified by:
        `compare` in interface `Comparator<Tuple<K,V>>`
      Parameters:
        `t1` - The first tuple
        `t2` - The second tuple
      Returns:
        There are 5 possible results :
        - -1 : the first key is below the second key
        - 0 : the two keys are equals, keys and values
        - 1 : the first key is above the second key

Copyright © 2012–2015 Apache Mavibot Project Parent. All rights reserved.