SSQLE
1.0
Simple SQL Editor
|
Class representing a history of commands executed during the runtime. More...
Public Member Functions | |||
CommandsHistory (int maxItems) | |||
| |||
void | Add (string item) | ||
Adds new item at the end of the history. If there is not space for that item (i.e. Count >= maxItems , then the oldest item is removed. More... | |||
bool | Remove (string item) | ||
Removes item from the list. More... | |||
void | Clear () | ||
Clears the list. More... | |||
bool | Contains (string item) | ||
Checks whether this container contains specified item. More... | |||
void | CopyTo (string[] array, int arrayIndex) | ||
Copies elements of this container to array pointed by array , starting at index arrayIndex . More... | |||
IEnumerator< string > | GetEnumerator () | ||
Gets the enumerator for the list More... | |||
int | IndexOf (string item) | ||
Index of specified item. More... | |||
void | Insert (int index, string item) | ||
Inserts an item to the list. More... | |||
void | RemoveAt (int index) | ||
Removes item at index . More... | |||
Public Attributes | |
int | Count => commands.Count |
Count of elements in the container. More... | |
bool | IsReadOnly => false |
Checks, whether this is read only container. Always false . More... | |
Properties | |
string | this[int index] [get, set] |
Indexer for the list. More... | |
Private Member Functions | |
void | RemoveFirst () |
Removes the oldest command from the history. Has O(maxItems) complexity. See CommandsHistory for more information. More... | |
IEnumerator IEnumerable. | GetEnumerator () |
Gets the enumerator for the list More... | |
Private Attributes | |
readonly IList< string > | commands = new List<string>() |
List of lastly used commands. More... | |
readonly int | maxItems |
Class representing a history of commands executed during the runtime.
It implements IList<string>
and is implemented internally using List<string>
. That means, RemoveFirst method has linear complexity (instead of assumed O(1), but since maxItems is likely to be in size of hundreds, it should not be an issue in real use case.
Implementation could be improved either by using Deque container, or using LinkedList
and maintaining LinkedListNode
instead of Editor.historyIndex.
SSQLE.CommandsHistory.CommandsHistory | ( | int | maxItems | ) |
maxItems | Maximal number of commands this instance can store. |
void SSQLE.CommandsHistory.Add | ( | string | item | ) |
Adds new item at the end of the history. If there is not space for that item (i.e. Count >= maxItems
, then the oldest item is removed.
item | Command to be stored. |
void SSQLE.CommandsHistory.Clear | ( | ) |
Clears the list.
bool SSQLE.CommandsHistory.Contains | ( | string | item | ) |
Checks whether this container contains specified item.
item | Item to chekc for. |
void SSQLE.CommandsHistory.CopyTo | ( | string[] | array, |
int | arrayIndex | ||
) |
Copies elements of this container to array pointed by array , starting at index arrayIndex .
array | Array to copy to. |
arrayIndex | Index in array from which to copy. |
IEnumerator<string> SSQLE.CommandsHistory.GetEnumerator | ( | ) |
Gets the enumerator for the list
|
private |
Gets the enumerator for the list
int SSQLE.CommandsHistory.IndexOf | ( | string | item | ) |
Index of specified item.
item | Item, which index is desired. |
-1
if item is not present in the list.void SSQLE.CommandsHistory.Insert | ( | int | index, |
string | item | ||
) |
Inserts an item to the list.
index | Index where to insert. |
item | Item to be inserted. |
bool SSQLE.CommandsHistory.Remove | ( | string | item | ) |
Removes item from the list.
item | Item to be removed. |
void SSQLE.CommandsHistory.RemoveAt | ( | int | index | ) |
Removes item at index .
index | Index of item to be removed. |
|
private |
Removes the oldest command from the history. Has O(maxItems) complexity. See CommandsHistory for more information.
|
private |
List of lastly used commands.
int SSQLE.CommandsHistory.Count => commands.Count |
Count of elements in the container.
bool SSQLE.CommandsHistory.IsReadOnly => false |
Checks, whether this is read only container. Always false
.
|
private |
|
getset |
Indexer for the list.
index | Index in the list. |