All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.lacuna.bifurcan.ISortedMap Maven / Gradle / Ivy

package io.lacuna.bifurcan;

import io.lacuna.bifurcan.IMap;

/**
 * @author ztellman
 */
public interface ISortedMap extends IMap {

  /**
   * @return the entry whose key is either equal to {@code key}, or just below it. If {@code key} is less than the
   * minimum value in the map, returns {@code null}.
   */
  IEntry floor(K key);

  /**
   * @return the entry whose key is either equal to {@code key}, or just above it. If {@code key} is greater than the
   * maximum value in the map, returns {@code null}.
   */
  IEntry ceil(K key);

  /**
   * @param min the inclusive minimum key value
   * @param max the inclusive maximum key value
   * @return a map representing all entries within [{@code} min, {@code} max]
   */
  ISortedMap slice(K min, K max);

  default IEntry first() {
    return nth(0);
  }

  default IEntry last() {
    return nth(size() - 1);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy