Enhanced C#
Language of your choice: library documentation
Public fields | Public static fields | Properties | Public Member Functions | Static Public Member Functions | List of all members
Loyc.Collections.StringSlice Struct Reference

A random-access slice of System.String. More...


Source file:
Inheritance diagram for Loyc.Collections.StringSlice:
Loyc.Collections.IRange< char > Loyc.Collections.ICharSource Loyc.ICloneable< StringSlice > Loyc.Collections.IListSource< char >

Remarks

A random-access slice of System.String.

Where possible, it is recommended that you use UString instead.

Note to self: I forgot why I made this type as a distinct entity from UString. Consider attempting to eliminate StringSlice.

Public fields

int _count
 

Public static fields

static StringSlice Empty = new StringSlice("")
 

Properties

string InternalString [get]
 
int InternalStart [get]
 
int Length [get]
 
int Count [get]
 
bool IsEmpty [get]
 
char First [get]
 
char Last [get]
 
char this[int index] [get]
 
char this[int index, char defaultValue] [get]
 
int this[int index, int defaultValue] [get]
 

Public Member Functions

 StringSlice (string list, int start, int count)
 Initializes a StringSlice. More...
 
 StringSlice (string str)
 
char PopFirst (out bool fail)
 
char PopLast (out bool fail)
 
IFRange< char > ICloneable< IFRange< char > >. Clone ()
 
IBRange< char > ICloneable< IBRange< char > >. Clone ()
 
IRange< char > ICloneable< IRange< char > >. Clone ()
 
StringSlice Clone ()
 
IEnumerator< char > IEnumerable< char >. GetEnumerator ()
 
System.Collections.IEnumerator System.Collections.IEnumerable. GetEnumerator ()
 
RangeEnumerator< StringSlice, char > GetEnumerator ()
 
char TryGet (int index, out bool fail)
 
IRange< char > IListSource< char >. Slice (int start, int count)
 Returns a substring from the character source. If some of the requested characters are past the end of the stream, the string is truncated to the available number of characters. More...
 
StringSlice Slice (int start, int count)
 Returns a substring from the character source. If some of the requested characters are past the end of the stream, the string is truncated to the available number of characters. More...
 
override int GetHashCode ()
 
override bool Equals (object obj)
 
bool Equals (StringSlice other)
 
override string ToString ()
 
- Public Member Functions inherited from Loyc.Collections.IListSource< char >
TryGet (int index, out bool fail)
 Gets the item at the specified index, and does not throw an exception on failure. More...
 
IRange< T > Slice (int start, int count=int.MaxValue)
 Returns a sub-range of this list. More...
 
- Public Member Functions inherited from Loyc.ICloneable< StringSlice >
Clone ()
 

Static Public Member Functions

static operator string (StringSlice s)
 
static implicit operator StringSlice (UString s)
 
static implicit operator UString (StringSlice s)
 
static implicit operator StringSlice (string s)
 

Constructor & Destructor Documentation

Loyc.Collections.StringSlice.StringSlice ( string  list,
int  start,
int  count 
)
inline

Initializes a StringSlice.

Exceptions
ArgumentExceptionThe start index was below zero.

The (start, count) range is allowed to be invalid, as long as 'start' is zero or above.

  • If 'count' is below zero, or if 'start' is above the original Length, the Count of the new slice is set to zero.
  • if (start + count) is above the original Length, the Count of the new slice is reduced to list.Length - start.

Member Function Documentation

IRange<char> IListSource<char>. Loyc.Collections.StringSlice.Slice ( int  startIndex,
int  length 
)
inline

Returns a substring from the character source. If some of the requested characters are past the end of the stream, the string is truncated to the available number of characters.

Parameters
startIndexIndex of first character to return. If startIndex >= Count, an empty string is returned.
lengthNumber of characters desired.
Exceptions
ArgumentExceptionThrown if startIndex or length are negative.

Implements Loyc.Collections.ICharSource.

References Loyc.Collections.StringSlice.Slice().

Referenced by Loyc.Collections.StringSlice.Slice(), and Loyc.UString.Slice().

StringSlice Loyc.Collections.StringSlice.Slice ( int  startIndex,
int  length 
)
inline

Returns a substring from the character source. If some of the requested characters are past the end of the stream, the string is truncated to the available number of characters.

Parameters
startIndexIndex of first character to return. If startIndex >= Count, an empty string is returned.
lengthNumber of characters desired.
Exceptions
ArgumentExceptionThrown if startIndex or length are negative.

Implements Loyc.Collections.ICharSource.

References Loyc.UString.InternalString.