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

io.sirix.index.art.EntrySet Maven / Gradle / Ivy

package io.sirix.index.art;

import java.util.AbstractSet;
import java.util.Iterator;
import java.util.Map;

class EntrySet extends AbstractSet> {
	private final AdaptiveRadixTree tree;

	EntrySet(AdaptiveRadixTree tree) {
		this.tree = tree;
	}

	@Override
	public Iterator> iterator() {
		return tree.entryIterator();
	}

	@Override
	public boolean contains(Object o) {
		if (!(o instanceof Map.Entry entry))
			return false;
		Object value = entry.getValue();
		LeafNode p = tree.getEntry(entry.getKey());
		return p != null && AdaptiveRadixTree.valEquals(p.getValue(), value);
	}

	@Override
	public boolean remove(Object o) {
		if (!(o instanceof Map.Entry entry))
			return false;
		Object value = entry.getValue();
		LeafNode p = tree.getEntry(entry.getKey());
		if (p != null && AdaptiveRadixTree.valEquals(p.getValue(), value)) {
			tree.deleteEntry(p);
			return true;
		}
		return false;
	}

	@Override
	public int size() {
		return tree.size();
	}

	@Override
	public void clear() {
		tree.clear();
	}

	// TODO: implement Spliterator
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy