Search Results for

    Show / Hide Table of Contents

    Class CharBuffer

    Buffer for characters. This approximates StringBuilder but is designed to be faster for specific operations. This is about 30% faster for the operations I'm interested in (Append, Clear, Length, ToString). This trades off memory for speed.

    Inheritance
    object
    CharBuffer
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: RTools_NTS.Util
    Assembly: NetTopologySuite.dll
    Syntax
    public class CharBuffer
    Remarks

    To make Remove from the head fast, this is implemented as a ring buffer.

    This uses head and tail indices into a fixed-size array. This will grow the array as necessary.

    Constructors

    | Edit this page View Source

    CharBuffer()

    Default constructor.

    Declaration
    public CharBuffer()
    | Edit this page View Source

    CharBuffer(int)

    Construct with a specific capacity.

    Declaration
    public CharBuffer(int capacity)
    Parameters
    Type Name Description
    int capacity

    Properties

    | Edit this page View Source

    Capacity

    Returns the capacity of this character buffer.

    Declaration
    public int Capacity { get; }
    Property Value
    Type Description
    int
    | Edit this page View Source

    this[int]

    Indexer.

    Declaration
    public char this[int index] { get; set; }
    Parameters
    Type Name Description
    int index
    Property Value
    Type Description
    char
    | Edit this page View Source

    Length

    Gets/Sets the number of characters in the character buffer. Increasing the length this way provides indeterminate results.

    Declaration
    public int Length { get; set; }
    Property Value
    Type Description
    int

    Methods

    | Edit this page View Source

    Append(CharBuffer)

    Append a string to this buffer.

    Declaration
    public void Append(CharBuffer s)
    Parameters
    Type Name Description
    CharBuffer s

    The string to append.

    | Edit this page View Source

    Append(char)

    Append a character to this buffer.

    Declaration
    public void Append(char c)
    Parameters
    Type Name Description
    char c
    | Edit this page View Source

    Append(string)

    Append a string to this buffer.

    Declaration
    public void Append(string s)
    Parameters
    Type Name Description
    string s

    The string to append.

    | Edit this page View Source

    CheckCapacity(int)

    Ensure that we're set for the requested length by potentially growing or shifting contents.

    Declaration
    protected void CheckCapacity(int requestedLength)
    Parameters
    Type Name Description
    int requestedLength
    | Edit this page View Source

    Clear()

    Empty the buffer.

    Declaration
    public void Clear()
    | Edit this page View Source

    Grow(int)

    Reallocate the buffer to be larger. For the new size, this uses the max of the requested length and double the current capacity. This does not shift, meaning it does not change the head or tail indices.

    Declaration
    protected void Grow(int requestedLen)
    Parameters
    Type Name Description
    int requestedLen

    The new requested length.

    | Edit this page View Source

    IndexOf(char)

    Find the first instance of a character in the buffer, and return its index. This returns -1 if the character is not found.

    Declaration
    public int IndexOf(char c)
    Parameters
    Type Name Description
    char c

    The character to find.

    Returns
    Type Description
    int

    The index of the specified character, or -1 for not found.

    | Edit this page View Source

    Remove(int)

    Remove a character at the specified index.

    Declaration
    public void Remove(int i)
    Parameters
    Type Name Description
    int i

    The index of the character to remove.

    | Edit this page View Source

    Remove(int, int)

    Remove a specified number of characters at the specified index.

    Declaration
    public void Remove(int i, int n)
    Parameters
    Type Name Description
    int i

    The index of the characters to remove.

    int n

    The number of characters to remove.

    | Edit this page View Source

    SetBuffer(char[], int)

    Overwrite this object's underlying buffer with the specified buffer.

    Declaration
    public void SetBuffer(char[] b, int len)
    Parameters
    Type Name Description
    char[] b

    The character array.

    int len

    The number of characters to consider filled in the input buffer.

    | Edit this page View Source

    ShiftToZero()

    Move the buffer contents such that headIndex becomes 0.

    Declaration
    protected void ShiftToZero()
    | Edit this page View Source

    ToString()

    Return the current contents as a string.

    Declaration
    public override string ToString()
    Returns
    Type Description
    string

    The new string.

    Overrides
    object.ToString()
    • Edit this page
    • View Source
    In this article
    Back to top Generated by DocFX