Prose.Mask

References
public struct Prose.Mask
Represents a boolean mask for each character in a string.

Constructors

Mask

#
public Mask(bool[] mask)
Create a new string mask.
mask (bool[])Masking booleans.

Mask

#
public Mask(int length, bool constantValue)
Create a new string mask containing only a single value.
length (int)Length of mask.
constantValue (bool)Value to assign to each element.

Properties

Empty

#
public static Prose.Mask Empty { get; }
Gets an empty mask.

Length

#
public int Length { get; }
Gets the length of the mask.

MaskedBlocks

#
public IEnumerable<(int start, int length)> MaskedBlocks { get; }
Enumerate over all the masked ranges.

MaskedCount

#
public int MaskedCount { get; }
Gets the number of true values in the mask.

UnmaskedBlocks

#
public IEnumerable<(int start, int length)> UnmaskedBlocks { get; }
Enumerate over all the unmasked ranges.

UnmaskedCount

#
public int UnmaskedCount { get; }
Gets the number of false values in the mask.

Indexers

this[]

#
public bool this[int index] { get; }
Gets the mask boolean at the given index.
index (int)

Methods

Apply

#
public string Apply(string target, char stamp = ' ')
Apply this mask to a string of the same length.
target (string)Target string.
stamp (char = ' ')Character to use whenever the mask is true.
Modified string.

Excise

#
public string Excise(string target)
Cut out all masked parts of a string.
target (string)Target string.
Excised string.

GrowMaskedBlocks

#
public Prose.Mask GrowMaskedBlocks()
Return a new mask whose masked blocks are one character bigger on either end.

IsFullyMasked

#
public bool IsFullyMasked(int index, int length)
Test whether the entire range is masked.
index (int)First index of range.
length (int)Length of range.
True if the entire range is masked.

IsFullyUnmasked

#
public bool IsFullyUnmasked(int index, int length)
Test whether the entire range is unmasked.
index (int)First index of range.
length (int)Length of range.
True if the entire range is masked.

IsMasked

#
public bool IsMasked(int index)
Gets whether the specific index is masked.
index (int)

IsUnmasked

#
public bool IsUnmasked(int index)
Gets whether the specific index is unmasked.
index (int)

ShrinkMaskedBlocks

#
public Prose.Mask ShrinkMaskedBlocks()
Return a new mask whose masked blocks are one character smaller on either end.

ToString

#
public override string ToString()
Gets a string representation of the mask.

ToString

#
public string ToString(char maskedSymbol, char unmaskedSymbol)
Gets a string representation of the mask.
maskedSymbol (char)Symbol to use for true values in the mask.
unmaskedSymbol (char)Symbol to use for false values in the mask.

Operators

OperationResultDescription
Prose.Mask&Prose.MaskProse.Mask'And' two masks together.
Prose.Mask|Prose.MaskProse.Mask'Or' two masks together.
!Prose.MaskProse.MaskNegate a string mask.