Package org.eclipse.rdf4j.model.impl
Class TreeModel
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<Statement>
-
- org.eclipse.rdf4j.model.impl.AbstractModel
-
- org.eclipse.rdf4j.model.impl.TreeModel
-
- All Implemented Interfaces:
Serializable
,Iterable<Statement>
,Collection<Statement>
,Set<Statement>
,SortedSet<Statement>
,Model
,NamespaceAware
public class TreeModel extends AbstractModel implements SortedSet<Statement>
A Red-Black tree basedModel
implementation. The model is sorted according to the lexical ordering of terms.This implementation provides guaranteed log(n) time cost for filtered access by any number of terms. If an index is not yet available for a set of positions, it is created at runtime using a
TreeSet
.Note that this implementation is not synchronized. If multiple threads access a model concurrently, even if all of them are read operations, it must be synchronized externally. This is typically accomplished by synchronizing on some object that naturally encapsulates the model. If no such object exists, the set should be "wrapped" using the Models.synchronizedModel method.
- Author:
- James Leigh
- See Also:
- Serialized Form
-
-
Method Summary
-
Methods inherited from class org.eclipse.rdf4j.model.impl.AbstractModel
add, addAll, clear, closeIterator, contains, containsAll, contexts, objects, predicates, remove, removeAll, retainAll, subjects, toArray, toArray, unmodifiable
-
Methods inherited from class java.util.AbstractSet
equals, hashCode
-
Methods inherited from class java.util.AbstractCollection
toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface org.eclipse.rdf4j.model.Model
getStatements
-
Methods inherited from interface java.util.Set
add, addAll, contains, containsAll, equals, hashCode, remove, removeAll, retainAll, toArray, toArray
-
Methods inherited from interface java.util.SortedSet
spliterator
-
-
-
-
Constructor Detail
-
TreeModel
public TreeModel()
-
TreeModel
public TreeModel(Model model)
-
TreeModel
public TreeModel(Collection<? extends Statement> c)
-
TreeModel
public TreeModel(Set<Namespace> namespaces, Collection<? extends Statement> c)
-
-
Method Detail
-
getNamespace
public Optional<Namespace> getNamespace(String prefix)
- Specified by:
getNamespace
in interfaceNamespaceAware
-
getNamespaces
public Set<Namespace> getNamespaces()
- Specified by:
getNamespaces
in interfaceNamespaceAware
-
setNamespace
public Namespace setNamespace(String prefix, String name)
- Specified by:
setNamespace
in interfaceModel
-
setNamespace
public void setNamespace(Namespace namespace)
- Specified by:
setNamespace
in interfaceModel
-
removeNamespace
public Optional<Namespace> removeNamespace(String prefix)
- Specified by:
removeNamespace
in interfaceModel
-
size
public int size()
- Specified by:
size
in interfaceCollection<Statement>
- Specified by:
size
in interfaceSet<Statement>
- Specified by:
size
in classAbstractCollection<Statement>
-
clear
public void clear()
- Specified by:
clear
in interfaceCollection<Statement>
- Specified by:
clear
in interfaceSet<Statement>
- Overrides:
clear
in classAbstractModel
-
comparator
public Comparator<? super Statement> comparator()
- Specified by:
comparator
in interfaceSortedSet<Statement>
-
pollFirst
public Statement pollFirst()
-
pollLast
public Statement pollLast()
-
removeTermIteration
public void removeTermIteration(Iterator<Statement> iterator, Resource subj, IRI pred, Value obj, Resource... contexts)
Description copied from class:AbstractModel
Called by aggregate sets when a term has been removed from a term iterator. Exactly one of the last four terms will be non-empty.- Specified by:
removeTermIteration
in classAbstractModel
- Parameters:
iterator
- The iterator used to navigate the live set (never null)subj
- the subject term to be removed or nullpred
- the predicate term to be removed or nullobj
- the object term to be removed or nullcontexts
- an array of one context term to be removed or an empty array
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfaceCollection<Statement>
- Specified by:
isEmpty
in interfaceSet<Statement>
- Overrides:
isEmpty
in classAbstractModel
-
-