public class ListBindingSet extends Object implements IBindingSet
An IBindingSet based on a LinkedList. Since Vars may
be compared using == this should be faster than a hash map for
most operations unless the binding set has a large number of entries.
Note: #push() and #pop(boolean) are implemented by making a
copy of the current symbol table with distinct Map.Entry objects. If
the symbol table is saved when it is #pop(boolean) popped), then it
simply replaces the pre-existing symbol table which was uncovered when it
was popped off of the stack. This design has several advantages, including:
null values or
delete markers.| Modifier | Constructor and Description |
|---|---|
|
ListBindingSet()
Create an empty binding set.
|
|
ListBindingSet(IVariable[] vars,
IConstant[] vals)
Alternative constructor.
|
protected |
ListBindingSet(ListBindingSet src,
IVariable[] variablesToKeep)
Copy constructor (used by clone, copy).
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear(IVariable var)
Clear any binding for the variable.
|
void |
clearAll()
Clear all bindings.
|
ListBindingSet |
clone()
Return a shallow copy of the binding set.
|
boolean |
containsErrorValues() |
IBindingSet |
copy(IVariable[] variablesToKeep)
Return a shallow copy of the binding set, eliminating unnecessary
variables.
|
IBindingSet |
copyMinusErrors(IVariable[] variablesToKeep)
Return a shallow copy of the binding set, eliminating unnecessary
variables and error values (equal to Constant.errorValueConstant()).
|
boolean |
equals(Object t)
True iff the variables and their bound values are the same
for the two binding sets.
|
IConstant |
get(IVariable var)
Return the binding for the variable.
|
int |
hashCode()
The hash code of a binding is defined as the bit-wise XOR of the hash
codes of the
IConstants for its bound variables. |
boolean |
isBound(IVariable var)
Return
true iff the variable is bound. |
boolean |
isEmpty()
true iff there are no variable bindings in the binding set. |
Iterator<Map.Entry<IVariable,IConstant>> |
iterator()
Visits the bindings.
|
void |
set(IVariable var,
IConstant val)
Bind the variable to the value.
|
int |
size()
The #of bound variables.
|
String |
toString() |
Iterator<IVariable> |
vars()
Visits the bound variables.
|
public ListBindingSet()
public ListBindingSet(IVariable[] vars, IConstant[] vals)
vars - A copy is made of the data.vals - A copy is made of the data.protected ListBindingSet(ListBindingSet src, IVariable[] variablesToKeep)
src - The source to be copied.variablesToKeep - The variables to be retained for the symbol table on the top
of the stack (optional).public ListBindingSet clone()
IBindingSetclone in interface IBindingSetclone in class Objectpublic IBindingSet copy(IVariable[] variablesToKeep)
IBindingSetcopy in interface IBindingSetvariablesToKeep - When non-null, only the listed variables are
retained.public final IBindingSet copyMinusErrors(IVariable[] variablesToKeep)
IBindingSetcopyMinusErrors in interface IBindingSetvariablesToKeep - When non-null, only the listed variables are
retained.public final boolean containsErrorValues()
containsErrorValues in interface IBindingSetpublic void clear(IVariable var)
IBindingSetclear in interface IBindingSetvar - The variable.public void clearAll()
IBindingSetclearAll in interface IBindingSetpublic IConstant get(IVariable var)
IBindingSetget in interface IBindingSetvar - The variable.null iff the
variable is not bound.public boolean isBound(IVariable var)
IBindingSettrue iff the variable is bound.isBound in interface IBindingSetvar - The variable.true if the variable is bound.public Iterator<Map.Entry<IVariable,IConstant>> iterator()
IBindingSetiterator in interface IBindingSetpublic void set(IVariable var, IConstant val)
IBindingSetset in interface IBindingSetvar - The variable.val - The value (MAY NOT be null).public boolean isEmpty()
IBindingSettrue iff there are no variable bindings in the binding set.isEmpty in interface IBindingSetpublic int size()
IBindingSetsize in interface IBindingSetpublic Iterator<IVariable> vars()
IBindingSetvars in interface IBindingSetpublic boolean equals(Object t)
IBindingSetequals in interface IBindingSetequals in class Objectt - Another binding set.public int hashCode()
IBindingSetIConstants for its bound variables. Unbound
variables are ignored when computing the hash code. Binding sets are
unordered collections, therefore the calculated hash code intentionally
does not depend on the order in which the bindings are visited. The hash
code reflects the current state of the bindings and must be recomputed if
the bindings are changed.hashCode in interface IBindingSethashCode in class ObjectCopyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.