TreeNode 1.5.2
A library to manipulate phylogenetic trees
Loading...
Searching...
No Matches
PhyloTree.TreeCollection Class Reference

Represents a collection of TreeNode objects. If the full representations of the TreeNode objects reside in memory, this offers the best performance at the expense of memory usage. Alternatively, the trees may be read on demand from a stream in binary format. In this case, accessing any of the trees will require the tree to be parsed. This reduces memory usage, but worsens performance. The internal storage model of the collection is transparent to consumers (except for the difference in performance/memory usage). More...

Inheritance diagram for PhyloTree.TreeCollection:

Public Member Functions

void Add (TreeNode item)
 Adds an element to the collection. This is stored in memory, even if the internal storage model of the collection is a Stream. More...
 
void AddRange (IEnumerable< TreeNode > items)
 Adds multiple elements to the collection. These are stored in memory, even if the internal storage model of the collection is a Stream. More...
 
IEnumerator< TreeNodeGetEnumerator ()
 Get an IEnumerator over the collection. More...
 
int IndexOf (TreeNode item)
 Finds the index of the first occurrence of an element in the collection. More...
 
void Insert (int index, TreeNode item)
 Inserts an element in the collection at the specified index. More...
 
void RemoveAt (int index)
 Removes from the collection the element at the specified index. More...
 
void Clear ()
 Removes all elements from the collection. If the internal storage model is a Stream, it is disposed and the internal storage model is converted to a List<TreeNode>. More...
 
bool Contains (TreeNode item)
 Determines whether the collection contains the specified element. More...
 
void CopyTo (TreeNode[] array, int arrayIndex)
 Copies the collection to an array. More...
 
bool Remove (TreeNode item)
 Removes the specified element from the collection. More...
 
 TreeCollection (List< TreeNode > internalStorage)
 Constructs a TreeCollection object from a List<TreeNode>. More...
 
 TreeCollection (Stream binaryTreeStream)
 Constructs a TreeCollection object from a stream of trees in binary format. More...
 
void Dispose ()
 Disposes the TreeCollection, the underlying Stream and StreamReader, and deletes the TemporaryFile (if applicable). More...
 

Properties

Stream UnderlyingStream = null [get]
 A stream containing the tree data in binary format, if this is the chosen storage model. This can be either a MemoryStream or a FileStream. More...
 
string TemporaryFile = null [get, set]
 If the trees are stored on disk in a temporary file, you should assign this property to the full path of the file. The file will be deleted when the TreeCollection is Dispose()d. More...
 
int Count [get]
 The number of trees in the collection. More...
 
bool IsReadOnly [get]
 Determine whether the collection is read-only. This is always false in the current implementation. More...
 
TreeNode this[int index] [get, set]
 Obtains an element from the collection. More...
 

Detailed Description

Represents a collection of TreeNode objects. If the full representations of the TreeNode objects reside in memory, this offers the best performance at the expense of memory usage. Alternatively, the trees may be read on demand from a stream in binary format. In this case, accessing any of the trees will require the tree to be parsed. This reduces memory usage, but worsens performance. The internal storage model of the collection is transparent to consumers (except for the difference in performance/memory usage).

Definition at line 16 of file TreeCollection.cs.

Constructor & Destructor Documentation

◆ TreeCollection() [1/2]

PhyloTree.TreeCollection.TreeCollection ( List< TreeNode internalStorage)

Constructs a TreeCollection object from a List<TreeNode>.

Parameters
internalStorageThe List<TreeNode> containing the trees to store in the collection. Note that this list is not copied, but used as-is.

Definition at line 429 of file TreeCollection.cs.

◆ TreeCollection() [2/2]

PhyloTree.TreeCollection.TreeCollection ( Stream  binaryTreeStream)

Constructs a TreeCollection object from a stream of trees in binary format.

Parameters
binaryTreeStreamThe stream of trees in binary format to use. The stream will be disposed when the TreeCollection is disposed. It should not be disposed earlier by external code.

Definition at line 439 of file TreeCollection.cs.

Member Function Documentation

◆ Add()

void PhyloTree.TreeCollection.Add ( TreeNode  item)

Adds an element to the collection. This is stored in memory, even if the internal storage model of the collection is a Stream.

Parameters
itemThe element to add.

Definition at line 161 of file TreeCollection.cs.

◆ AddRange()

void PhyloTree.TreeCollection.AddRange ( IEnumerable< TreeNode items)

Adds multiple elements to the collection. These are stored in memory, even if the internal storage model of the collection is a Stream.

Parameters
itemsThe elements to add.

Definition at line 174 of file TreeCollection.cs.

◆ Clear()

void PhyloTree.TreeCollection.Clear ( )

Removes all elements from the collection. If the internal storage model is a Stream, it is disposed and the internal storage model is converted to a List<TreeNode>.

Definition at line 329 of file TreeCollection.cs.

◆ Contains()

bool PhyloTree.TreeCollection.Contains ( TreeNode  item)

Determines whether the collection contains the specified element.

Parameters
itemThe element to search for.
Returns
true if the collection contains the specified element, false otherwise.

Definition at line 356 of file TreeCollection.cs.

◆ CopyTo()

void PhyloTree.TreeCollection.CopyTo ( TreeNode[]  array,
int  arrayIndex 
)

Copies the collection to an array.

Parameters
arrayThe array in which to copy the collection.
arrayIndexThe index at which to start the copy.

Definition at line 383 of file TreeCollection.cs.

◆ Dispose()

void PhyloTree.TreeCollection.Dispose ( )

Disposes the TreeCollection, the underlying Stream and StreamReader, and deletes the TemporaryFile (if applicable).

Definition at line 513 of file TreeCollection.cs.

◆ GetEnumerator()

IEnumerator< TreeNode > PhyloTree.TreeCollection.GetEnumerator ( )

Get an IEnumerator over the collection.

Returns
An IEnumerator over the collection.

Definition at line 191 of file TreeCollection.cs.

◆ IndexOf()

int PhyloTree.TreeCollection.IndexOf ( TreeNode  item)

Finds the index of the first occurrence of an element in the collection.

Parameters
itemThe item to search for.
Returns
The index of the item in the collection.

Definition at line 244 of file TreeCollection.cs.

◆ Insert()

void PhyloTree.TreeCollection.Insert ( int  index,
TreeNode  item 
)

Inserts an element in the collection at the specified index.

Parameters
indexThe index at which to insert the element.
itemThe element to insert.

Definition at line 271 of file TreeCollection.cs.

◆ Remove()

bool PhyloTree.TreeCollection.Remove ( TreeNode  item)

Removes the specified element from the collection.

Parameters
itemThe element to remove.
Returns
true if the removal was successful (i.e. the list contained the element in the first place), false otherwise.

Definition at line 404 of file TreeCollection.cs.

◆ RemoveAt()

void PhyloTree.TreeCollection.RemoveAt ( int  index)

Removes from the collection the element at the specified index.

Parameters
index

Definition at line 298 of file TreeCollection.cs.

Property Documentation

◆ Count

int PhyloTree.TreeCollection.Count
get

The number of trees in the collection.

Definition at line 87 of file TreeCollection.cs.

◆ IsReadOnly

bool PhyloTree.TreeCollection.IsReadOnly
get

Determine whether the collection is read-only. This is always false in the current implementation.

Definition at line 105 of file TreeCollection.cs.

◆ TemporaryFile

string PhyloTree.TreeCollection.TemporaryFile = null
getset

If the trees are stored on disk in a temporary file, you should assign this property to the full path of the file. The file will be deleted when the TreeCollection is Dispose()d.

Definition at line 82 of file TreeCollection.cs.

◆ this[int index]

TreeNode PhyloTree.TreeCollection.this[int index]
getset

Obtains an element from the collection.

Parameters
indexThe index of the element to extract.
Returns
The requested element from the collection.

Definition at line 112 of file TreeCollection.cs.

◆ UnderlyingStream

Stream PhyloTree.TreeCollection.UnderlyingStream = null
get

A stream containing the tree data in binary format, if this is the chosen storage model. This can be either a MemoryStream or a FileStream.

Definition at line 26 of file TreeCollection.cs.


The documentation for this class was generated from the following file: