Class RotatedTextWithTerminator
A text string with a terminator character which has been rotated leftwards or rightwards, of a number of positions (0 included).
Inheritance
Implements
Inherited Members
Namespace: MoreStructures
Assembly: MoreStructures.dll
Syntax
public class RotatedTextWithTerminator : IValueEnumerable<char>, IEquatable<RotatedTextWithTerminator>
Remarks
USECASES
- A terminator-terminated rotated text is required by Burrows-Wheeler Transform operations, such as inversion.
- This object provides type safety, as it allows to tell apart rotated terminator-terminated strings from
generic ones.
- Consistently using RotatedTextWithTerminator, rather than System.String, in all library
functionalities ensures that the invariant of a rotated terminator-terminated string is always respected.
- Most string-related functionalities provided by RotatedTextWithTerminator, such as
Length and Item[Index], as well as
Constructors
| Improve this Doc View SourceRotatedTextWithTerminator(IEnumerable<Char>, Char, Boolean)
A text string with a terminator character which has been rotated leftwards or rightwards, of a number of positions (0 included).
Declaration
public RotatedTextWithTerminator(IEnumerable<char> RotatedText, char Terminator = '$', bool ValidateInput = true)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.IEnumerable<System.Char> | RotatedText | The text, defined as an |
System.Char | Terminator | A terminator character, present in the text at most once. If not specified DefaultTerminator is used. |
System.Boolean | ValidateInput | Whether the input, and in particular RotatedText should be validated, while this object is created. Validation takes O(n) time, where n = number of chars in RotatedText and can be an heavy operation. |
Remarks
USECASES
- A terminator-terminated rotated text is required by Burrows-Wheeler Transform operations, such as inversion.
- This object provides type safety, as it allows to tell apart rotated terminator-terminated strings from
generic ones.
- Consistently using RotatedTextWithTerminator, rather than System.String, in all library
functionalities ensures that the invariant of a rotated terminator-terminated string is always respected.
- Most string-related functionalities provided by RotatedTextWithTerminator, such as
Length and Item[Index], as well as
Properties
| Improve this Doc View SourceItem[Index]
Select a part of RotatedText by the provided index (either w.r.t. the start or to the end of the text).
Declaration
public char this[Index index] { get; }
Parameters
Type | Name | Description |
---|---|---|
Index | index | The index applied to the underlying string. |
Property Value
Type | Description |
---|---|
System.Char | A char containing the selected part. |
Item[TextWithTerminator.ISelector]
Select a part of RotatedText by the provided selector.
Declaration
public string this[TextWithTerminator.ISelector selector] { get; }
Parameters
Type | Name | Description |
---|---|---|
TextWithTerminator.ISelector | selector | Any selector acting on a RotatedTextWithTerminator. |
Property Value
Type | Description |
---|---|
System.String | A string containing the selected part. |
Item[Range]
Select a part of RotatedText by the provided range (start index included, end index excluded).
Declaration
public IEnumerable<char> this[Range range] { get; }
Parameters
Type | Name | Description |
---|---|---|
Range | range | The range applied to the underlying string. |
Property Value
Type | Description |
---|---|
System.Collections.IEnumerable<System.Char> | A sequence of chars containing the selected part. |
Length
The total length of RotatedText, including the terminator.
Declaration
public int Length { get; }
Property Value
Type | Description |
---|---|
System.Int32 | A positive integer (at least 1). |
Remarks
RotatedText
Declaration
public IEnumerable<char> RotatedText { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.IEnumerable<System.Char> | A sequence of chars. |
Remarks
Wrapped into a IValueEnumerable<T> to preserve value equality.
Terminator
Declaration
public char Terminator { get; set; }
Property Value
Type | Description |
---|---|
System.Char | A single char. |
ValidateInput
Declaration
public bool ValidateInput { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
| Improve this Doc View SourceEndsWith(String)
Whether this text ends with suffix
.
Declaration
public bool EndsWith(string suffix)
Parameters
Type | Name | Description |
---|---|---|
System.String | suffix | A terminator-included string. |
Returns
Type | Description |
---|---|
System.Boolean | True if RotatedText ends by |
GetEnumerator()
Returns an enumerator that iterates through the collection of chars of the underlying RotatedText string, including the Terminator char.
Declaration
public IEnumerator<char> GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.IEnumerator<System.Char> |
StartsWith(String)
Whether this text starts with prefix
.
Declaration
public bool StartsWith(string prefix)
Parameters
Type | Name | Description |
---|---|---|
System.String | prefix | A terminator-included string. |
Returns
Type | Description |
---|---|
System.Boolean | True if RotatedText starts by |
Explicit Interface Implementations
| Improve this Doc View SourceIEnumerable.GetEnumerator()
Returns an enumerator that iterates through the collection of chars of the underlying RotatedText string, including the Terminator char.
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.IEnumerator |