AvalonEdit
TextSegmentCollection<(Of <(<'T>)>)> Class
NamespacesICSharpCode.AvalonEdit.DocumentTextSegmentCollection<(Of <(<'T>)>)>

A collection of text segments that supports efficient lookup of segments intersecting with another segment.

Declaration Syntax
C#Visual BasicVisual C++
public sealed class TextSegmentCollection<T> : ICollection<T>, 
	IEnumerable<T>, IEnumerable, ISegmentTree, IWeakEventListener
where T : TextSegment
Public NotInheritable Class TextSegmentCollection(Of T As TextSegment) _
	Implements ICollection(Of T), IEnumerable(Of T),  _
	IEnumerable, ISegmentTree, IWeakEventListener
generic<typename T>
where T : TextSegment
public ref class TextSegmentCollection sealed : ICollection<T>, 
	IEnumerable<T>, IEnumerable, ISegmentTree, IWeakEventListener
Generic Template Parameters
T
Members
All MembersConstructorsMethodsProperties



IconMemberDescription
TextSegmentCollection<(Of <(<'T>)>)>()()()()
Creates a new TextSegmentCollection that needs manual calls to UpdateOffsets(DocumentChangeEventArgs).

TextSegmentCollection<(Of <(<'T>)>)>(TextDocument)
Creates a new TextSegmentCollection that updates the offsets automatically.

Add(T)
Adds the specified segment to the tree. This will cause the segment to update when the document changes.

Clear()()()()
Removes all segments from the tree.

Contains(T)
Gets whether this tree contains the specified item.

CopyTo(array<T>[]()[][], Int32)
Copies all segments in this SegmentTree to the specified array.

Count
Gets the number of segments in the tree.

Equals(Object)
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
FindFirstSegmentWithStartAfter(Int32)
Gets the first segment with a start offset greater or equal to startOffset. Returns null if no such segment is found.

FindOverlappingSegments(ISegment)
Finds all segments that overlap with the given segment (including touching segments).

FindOverlappingSegments(Int32, Int32)
Finds all segments that overlap with the given segment (including touching segments). Segments are returned in the order given by GetNextSegment/GetPreviousSegment.

FindSegmentsContaining(Int32)
Finds all segments that contain the given offset. (StartOffset <= offset <= EndOffset) Segments are returned in the order given by GetNextSegment/GetPreviousSegment.

FirstSegment
Returns the first segment in the collection or null, if the collection is empty.

GetEnumerator()()()()
Gets an enumerator to enumerate the segments.

GetHashCode()()()()
Serves as a hash function for a particular type.
(Inherited from Object.)
GetNextSegment(T)
Gets the next segment after the specified segment. Segments are sorted by their start offset. Returns null if segment is the last segment.

GetPreviousSegment(T)
Gets the previous segment before the specified segment. Segments are sorted by their start offset. Returns null if segment is the first segment.

GetType()()()()
Gets the Type of the current instance.
(Inherited from Object.)
LastSegment
Returns the last segment in the collection or null, if the collection is empty.

Remove(T)
Removes the specified segment from the tree. This will cause the segment to not update anymore when the document changes.

ToString()()()()
Returns a String that represents the current Object.
(Inherited from Object.)
UpdateOffsets(DocumentChangeEventArgs)
Updates the start and end offsets of all segments stored in this collection.

UpdateOffsets(OffsetChangeMapEntry)
Updates the start and end offsets of all segments stored in this collection.

Remarks

A TextSegment can be stand-alone or part of a TextSegmentCollection<(Of <(<'T>)>)>. If the segment is stored inside a TextSegmentCollection, its Offset and Length will be updated by that collection.

When the document changes, the offsets of all text segments in the TextSegmentCollection will be adjusted accordingly. Start offsets move like AnchorMovementType.AfterInsertion, end offsets move like AnchorMovementType.BeforeInsertion (i.e. the segment will always stay as small as possible).

If a document change causes a segment to be deleted completely, it will be reduced to length 0, but segments are never automatically removed from the collection. Segments with length 0 will never expand due to document changes, and they move as AfterInsertion.

Thread-safety: a TextSegmentCollection that is connected to a TextDocument may only be used on that document's owner thread. A disconnected TextSegmentCollection is safe for concurrent reads, but concurrent access is not safe when there are writes. Keep in mind that reading the Offset properties of a text segment inside the collection is a read access on the collection; and setting an Offset property of a text segment is a write access on the collection.

Inheritance Hierarchy
Object
TextSegmentCollection<(Of <(<'T>)>)>

Assembly: ICSharpCode.AvalonEdit (Module: ICSharpCode.AvalonEdit.dll) Version: 5.0.0.4238