|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectlp.unit.EmptyProgram
class EmptyProgram
An efficient implementation of an empty logic program that is immutable. May be useful in some cases :o)
LogicProgram
,
DynamicLogicProgram
Field Summary | |
---|---|
private static Object[] |
AS_ARRAY
Empty array used to return the program as an of rules. |
private static EmptyProgram |
instance
The singleton instance. |
private static Iterator<LpRule> |
ITR
A static iterator over an empty collection of rules. |
Constructor Summary | |
---|---|
private |
EmptyProgram()
A private constructor because this class is a singleton. |
Method Summary | ||
---|---|---|
boolean |
add(LpRule r)
Throws an UnsupportedOperationException . |
|
boolean |
addAll(Collection<? extends LpRule> c)
Throws an UnsupportedOperationException . |
|
void |
clear()
Throws an UnsupportedOperationException . |
|
boolean |
contains(Object o)
Returns false . |
|
boolean |
containsAll(Collection<?> c)
Returns the same as c.isEmpty() . |
|
boolean |
equals(Object obj)
Returns true iff obj implements the LogicProgram
interface and contains no rules. |
|
LpRule |
get(int index)
Throws an IndexOutOfBoundsException . |
|
static EmptyProgram |
getInstance()
Returns the singleton instance. |
|
int |
hashCode()
Returns the hash code of an empty set. |
|
boolean |
isEmpty()
Returns true . |
|
boolean |
isGround()
Returns true . |
|
Iterator<LpRule> |
iterator()
Returns the iterator for this empty collection. |
|
boolean |
remove(Object o)
Throws an UnsupportedOperationException . |
|
boolean |
removeAll(Collection<?> c)
Throws an UnsupportedOperationException . |
|
boolean |
retainAll(Collection<?> c)
Throws an UnsupportedOperationException . |
|
int |
size()
Returns 0. |
|
Object[] |
toArray()
Returns an empty array. |
|
|
toArray(T[] a)
Returns an empty array. |
|
String |
toString()
Returns the string "[]". |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static EmptyProgram instance
private static final Iterator<LpRule> ITR
private static final Object[] AS_ARRAY
Constructor Detail |
---|
private EmptyProgram()
Method Detail |
---|
public static EmptyProgram getInstance()
EmptyProgram
public int size()
size
in interface Collection<LpRule>
size
in interface Set<LpRule>
public boolean isEmpty()
true
.
isEmpty
in interface Collection<LpRule>
isEmpty
in interface Set<LpRule>
true
public boolean contains(Object o)
false
.
contains
in interface Collection<LpRule>
contains
in interface Set<LpRule>
o
- the object to look for (cannot be contained in an empty
collection)
false
public Iterator<LpRule> iterator()
iterator
in interface Iterable<LpRule>
iterator
in interface Collection<LpRule>
iterator
in interface Set<LpRule>
public Object[] toArray()
toArray
in interface Collection<LpRule>
toArray
in interface Set<LpRule>
public <T> T[] toArray(T[] a)
toArray
in interface Collection<LpRule>
toArray
in interface Set<LpRule>
public boolean add(LpRule r)
UnsupportedOperationException
.
add
in interface Collection<LpRule>
add
in interface Set<LpRule>
r
- the rule to add
UnsupportedOperationException
- alwayspublic boolean remove(Object o)
UnsupportedOperationException
.
remove
in interface Collection<LpRule>
remove
in interface Set<LpRule>
o
- the rule to remove
UnsupportedOperationException
- alwayspublic boolean containsAll(Collection<?> c)
c.isEmpty()
.
containsAll
in interface Collection<LpRule>
containsAll
in interface Set<LpRule>
public boolean addAll(Collection<? extends LpRule> c)
UnsupportedOperationException
.
addAll
in interface Collection<LpRule>
addAll
in interface Set<LpRule>
c
- the collection of rules to add
UnsupportedOperationException
- alwayspublic boolean removeAll(Collection<?> c)
UnsupportedOperationException
.
removeAll
in interface Collection<LpRule>
removeAll
in interface Set<LpRule>
c
- the collection of rules to remove
UnsupportedOperationException
- alwayspublic boolean retainAll(Collection<?> c)
UnsupportedOperationException
.
retainAll
in interface Collection<LpRule>
retainAll
in interface Set<LpRule>
c
- the collection of rules to retain
UnsupportedOperationException
- alwayspublic LpRule get(int index)
IndexOutOfBoundsException
.
get
in interface LogicProgram
index
- the index of the rule to return
IndexOutOfBoundsException
- alwayspublic void clear()
UnsupportedOperationException
.
clear
in interface Collection<LpRule>
clear
in interface Set<LpRule>
UnsupportedOperationException
- alwayspublic boolean equals(Object obj)
true
iff obj
implements the LogicProgram
interface and contains no rules.
equals
in interface Collection<LpRule>
equals
in interface Set<LpRule>
equals
in class Object
obj
- the object to compare with
public int hashCode()
hashCode
in interface Collection<LpRule>
hashCode
in interface Set<LpRule>
hashCode
in class Object
Collections.emptySet()
public boolean isGround()
true
.
isGround
in interface LogicProgram
true
LpGroundDecider.isGround(LpStructureUnit)
public String toString()
toString
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |