Package emissary.directory
Class DirectoryEntryList
- java.lang.Object
-
- java.util.concurrent.CopyOnWriteArrayList<DirectoryEntry>
-
- emissary.directory.DirectoryEntryList
-
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<DirectoryEntry>
,Collection<DirectoryEntry>
,List<DirectoryEntry>
,RandomAccess
public class DirectoryEntryList extends CopyOnWriteArrayList<DirectoryEntry>
Hold a set of Directory keys (four-tuples) in sorted order by expense, cheapest first, no duplicates- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static boolean
DEEP_COPY
Value of DEEP_COPY flagstatic String
ENTRYLIST
Xml value of entry list elementstatic boolean
PRESERVE_TIME
Value of PRESERVE_TIME flagstatic boolean
SHALLOW_COPY
Value of SHALLOW_COPY flag
-
Constructor Summary
Constructors Modifier Constructor Description DirectoryEntryList()
DirectoryEntryList(DirectoryEntryList list)
Create one from an existing DirectoryEntryList Makes a shallow copy of the argument listDirectoryEntryList(DirectoryEntryList list, boolean deepCopy)
Create one from an existing DirectoryEntryListprotected
DirectoryEntryList(DirectoryEntryList list, boolean deepCopy, boolean preserveTime)
Create one from an existing DirectoryEntryList
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(DirectoryEntry o)
Add a new DirectoryEntryboolean
addAll(Collection<? extends DirectoryEntry> c)
Add entries from a collection.static List<DirectoryEntry>
deepCopy(List<DirectoryEntry> that, boolean sort)
Utility method to make a deep copy of a List<DirectoryEntry>static DirectoryEntryList
fromXml(org.jdom2.Element e)
Build an entry list from the supplied xml fragmentDirectoryEntry
getEntry(int i)
Get entry at specified positionorg.jdom2.Element
getXml()
Turn this list into an XML fragmentDirectoryEntry
pickOneOf(int desiredExpense)
Pick one of any that are tied for expense at randomvoid
sort()
Sort the list when we have made external cost modifications-
Methods inherited from class java.util.concurrent.CopyOnWriteArrayList
add, addAll, addAllAbsent, addIfAbsent, clear, clone, contains, containsAll, equals, forEach, get, hashCode, indexOf, indexOf, isEmpty, iterator, lastIndexOf, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, stream, toArray
-
-
-
-
Field Detail
-
ENTRYLIST
public static final String ENTRYLIST
Xml value of entry list element- See Also:
- Constant Field Values
-
DEEP_COPY
public static final boolean DEEP_COPY
Value of DEEP_COPY flag- See Also:
- Constant Field Values
-
SHALLOW_COPY
public static final boolean SHALLOW_COPY
Value of SHALLOW_COPY flag- See Also:
- Constant Field Values
-
PRESERVE_TIME
public static final boolean PRESERVE_TIME
Value of PRESERVE_TIME flag- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DirectoryEntryList
public DirectoryEntryList()
-
DirectoryEntryList
public DirectoryEntryList(DirectoryEntryList list)
Create one from an existing DirectoryEntryList Makes a shallow copy of the argument list- Parameters:
list
- the existing list to copy into this one
-
DirectoryEntryList
public DirectoryEntryList(DirectoryEntryList list, boolean deepCopy)
Create one from an existing DirectoryEntryList- Parameters:
list
- the existing list to copy into this onedeepCopy
- true if should be a deep copy
-
DirectoryEntryList
protected DirectoryEntryList(@Nullable DirectoryEntryList list, boolean deepCopy, boolean preserveTime)
Create one from an existing DirectoryEntryList- Parameters:
list
- the existing list to copy into this onedeepCopy
- true if should be a deep copypreserveTime
- true if time should be preserved on entries
-
-
Method Detail
-
addAll
public boolean addAll(Collection<? extends DirectoryEntry> c)
Add entries from a collection. Does not make a deep copy from collection, just adds them- Specified by:
addAll
in interfaceCollection<DirectoryEntry>
- Specified by:
addAll
in interfaceList<DirectoryEntry>
- Overrides:
addAll
in classCopyOnWriteArrayList<DirectoryEntry>
- Parameters:
c
- the collection to add from- Returns:
- true if the list is changed by this call
-
add
public boolean add(DirectoryEntry o)
Add a new DirectoryEntry- Specified by:
add
in interfaceCollection<DirectoryEntry>
- Specified by:
add
in interfaceList<DirectoryEntry>
- Overrides:
add
in classCopyOnWriteArrayList<DirectoryEntry>
- Parameters:
o
- the DirectoryEntry object to add- Returns:
- true as per general contract of Collection.add
-
getEntry
public DirectoryEntry getEntry(int i)
Get entry at specified position- Parameters:
i
- the position- Returns:
- DirectoryEntry at position i
-
sort
public void sort()
Sort the list when we have made external cost modifications
-
pickOneOf
public DirectoryEntry pickOneOf(int desiredExpense)
Pick one of any that are tied for expense at random- Parameters:
desiredExpense
- the expense we want
-
fromXml
public static DirectoryEntryList fromXml(org.jdom2.Element e)
Build an entry list from the supplied xml fragment
-
getXml
public org.jdom2.Element getXml()
Turn this list into an XML fragment
-
deepCopy
public static List<DirectoryEntry> deepCopy(@Nullable List<DirectoryEntry> that, boolean sort)
Utility method to make a deep copy of a List<DirectoryEntry>- Parameters:
that
- the list to copysort
- true if returned list should be sorted- Returns:
- the new list
-
-