public class SmallDefinitionSet extends Object implements IMutableDefinitionSet
IMutableDefinitionSet set that can hold
only a small and fixed number -- currently 2 -- of definitions.
Note that this class simply stores its two definitions in two fields and does not require a separate array.
95% of definition sets contain only a single definition,
which is why DefinitionBase implements IDefinitionSet
to make a single definition act as a set of size 1.
Most of the other 5% of definition sets contain only two
definitions, typically for a getter/setter pair,
and can use SmallDefinitionSet; this class is for them.
Less than 1% of definitions sets contain more than 2 definitions
and must use LargeDefinitionSet.
| Constructor and Description |
|---|
SmallDefinitionSet(IDefinition definition0,
IDefinition definition1)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addDefinition(IDefinition definition)
Adds a definition to this set.
|
IDefinition |
getDefinition(int i)
Gets a definition in this set, by index.
|
int |
getMaxSize() |
int |
getSize() |
boolean |
isEmpty()
Determines if this definition set is empty.
|
void |
removeDefinition(IDefinition definition)
Removes a definition from this set.
|
void |
replaceDefinition(int i,
IDefinition newDefinition)
Replaces the
IDefinition at the specified index with a new
definition. |
String |
toString()
For debugging only.
|
public SmallDefinitionSet(IDefinition definition0, IDefinition definition1)
public boolean isEmpty()
IDefinitionSetisEmpty in interface IDefinitionSettrue if the definition set is empty.public int getSize()
getSize in interface IDefinitionSetpublic int getMaxSize()
getMaxSize in interface IDefinitionSetpublic IDefinition getDefinition(int i)
IDefinitionSetgetDefinition in interface IDefinitionSeti - The index of the definition.IDefinition for the definition.public void addDefinition(IDefinition definition)
IMutableDefinitionSetaddDefinition in interface IMutableDefinitionSetdefinition - The IDefinition to add.public void removeDefinition(IDefinition definition)
IMutableDefinitionSetremoveDefinition in interface IMutableDefinitionSetdefinition - The IDefinitionNode to remove.public void replaceDefinition(int i,
IDefinition newDefinition)
IMutableDefinitionSetIDefinition at the specified index with a new
definition.replaceDefinition in interface IMutableDefinitionSeti - The index of the IDefinition to replace.newDefinition - The new IDefinition to store in the set.Copyright © 2016 The Apache Software Foundation. All rights reserved.