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

swim.util.OrderedMap Maven / Gradle / Ivy

Go to download

Extended collection, iterator, and builder interfaces, lightweight cache sets and maps, and other foundational utilities

There is a newer version: 4.3.15
Show newest version
// Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package swim.util;

import java.util.Collection;
import java.util.Comparator;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;

public interface OrderedMap extends IterableMap, SortedMap {
  @Override
  boolean isEmpty();

  @Override
  int size();

  @Override
  boolean containsKey(Object key);

  @Override
  boolean containsValue(Object value);

  int indexOf(Object key);

  @Override
  V get(Object key);

  Entry getEntry(Object key);

  Entry getIndex(int index);

  Entry firstEntry();

  @Override
  K firstKey();

  V firstValue();

  Entry lastEntry();

  @Override
  K lastKey();

  V lastValue();

  Entry nextEntry(K key);

  K nextKey(K key);

  V nextValue(K key);

  Entry previousEntry(K key);

  K previousKey(K key);

  V previousValue(K key);

  @Override
  V put(K key, V newValue);

  @Override
  default void putAll(Map map) {
    for (Entry entry : map.entrySet()) {
      put(entry.getKey(), entry.getValue());
    }
  }

  @Override
  V remove(Object key);

  @Override
  void clear();

  @Override
  default OrderedMap headMap(K toKey) {
    return new OrderedMapView(this, null, toKey);
  }

  @Override
  default OrderedMap tailMap(K fromKey) {
    return new OrderedMapView(this, fromKey, null);
  }

  @Override
  default OrderedMap subMap(K fromKey, K toKey) {
    return new OrderedMapView(this, fromKey, toKey);
  }

  @Override
  default Set> entrySet() {
    return IterableMap.super.entrySet();
  }

  @Override
  default Set keySet() {
    return IterableMap.super.keySet();
  }

  @Override
  default Collection values() {
    return IterableMap.super.values();
  }

  @Override
  OrderedMapCursor iterator();

  @Override
  default Cursor keyIterator() {
    return IterableMap.super.keyIterator();
  }

  @Override
  default Cursor valueIterator() {
    return IterableMap.super.valueIterator();
  }

  @Override
  Comparator comparator();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy