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

org.jhotdraw8.icollection.impl.redblack.Empty Maven / Gradle / Ivy

/*
 * @(#)Empty.java
 * Copyright © 2023 The authors and contributors of JHotDraw. MIT License.
 */
package org.jhotdraw8.icollection.impl.redblack;

import org.jspecify.annotations.Nullable;

import java.util.Comparator;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.function.BiFunction;

/**
 * The empty tree node.
 * 

* This class has been derived from 'vavr' RedBlackTree.java. *

*
RedBlackTree.java. Copyright 2023 (c) vavr. MIT License.
*
github.com
*
* * @param Component type */ public final class Empty implements RedBlackTree { public final static Empty EMPTY = new Empty<>(); @SuppressWarnings("unchecked") public static Empty empty() { return (Empty) EMPTY; } private Empty() { } @Override public boolean color() { return Color.BLACK; } @Override public boolean contains(K key, Comparator comparator) { return false; } @Override public RedBlackTree find(K key, Comparator comparator) { return this; } @Override public RedBlackTree ceiling(K e, Comparator comparator) { return this; } @Override public RedBlackTree floor(K e, Comparator comparator) { return this; } @Override public RedBlackTree higher(K e, Comparator comparator) { return this; } @Override public RedBlackTree orElse(RedBlackTree other) { return other; } @Override public RedBlackTree lower(K e, Comparator comparator) { return this; } @Override public boolean isEmpty() { return true; } @Override public RedBlackTree left() { throw new UnsupportedOperationException("left on empty"); } @Override public RedBlackTree right() { throw new UnsupportedOperationException("right on empty"); } @Override public int size() { return 0; } @Override public K getKey() { throw new NoSuchElementException("key on empty"); } @Override public V getValue() { throw new NoSuchElementException("value on empty"); } @Override public @Nullable K keyOrNull() { return null; } @Override public @Nullable V valueOrNull() { return null; } @Override public @Nullable E mapOrNull(BiFunction f) { return null; } @Override public Map.@Nullable Entry entryOrNull() { return null; } @Override public boolean isRed() { return false; } @Override public String toString() { return "()"; } @Override public String toLispString() { return "()"; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy