SSQLE  1.0
Simple SQL Editor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties
Public Member Functions | Public Attributes | Properties | Private Member Functions | Private Attributes | List of all members
SSQLE.CommandsHistory Class Reference

Class representing a history of commands executed during the runtime. More...

Inheritance diagram for SSQLE.CommandsHistory:

Public Member Functions

 CommandsHistory (int maxItems)
 
Parameters
maxItemsMaximal number of commands this instance can store.
More...
 
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
 

Detailed Description

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.

Constructor & Destructor Documentation

SSQLE.CommandsHistory.CommandsHistory ( int  maxItems)

Parameters
maxItemsMaximal number of commands this instance can store.

Member Function Documentation

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.

Parameters
itemCommand to be stored.
See also
RemoveFirst
void SSQLE.CommandsHistory.Clear ( )

Clears the list.

bool SSQLE.CommandsHistory.Contains ( string  item)

Checks whether this container contains specified item.

Parameters
itemItem to chekc for.
Returns
True if contains, false otherwise.
void SSQLE.CommandsHistory.CopyTo ( string[]  array,
int  arrayIndex 
)

Copies elements of this container to array pointed by array , starting at index arrayIndex .

Parameters
arrayArray to copy to.
arrayIndexIndex in array from which to copy.
IEnumerator<string> SSQLE.CommandsHistory.GetEnumerator ( )

Gets the enumerator for the list

Returns
Enumerator of the list.
IEnumerator IEnumerable. SSQLE.CommandsHistory.GetEnumerator ( )
private

Gets the enumerator for the list

Returns
Enumerator of the list.
int SSQLE.CommandsHistory.IndexOf ( string  item)

Index of specified item.

Parameters
itemItem, which index is desired.
Returns
Index of such item, or -1 if item is not present in the list.
void SSQLE.CommandsHistory.Insert ( int  index,
string  item 
)

Inserts an item to the list.

Parameters
indexIndex where to insert.
itemItem to be inserted.
bool SSQLE.CommandsHistory.Remove ( string  item)

Removes item from the list.

Parameters
itemItem to be removed.
Returns
True if item were present in the list, false otherwise.
void SSQLE.CommandsHistory.RemoveAt ( int  index)

Removes item at index .

Parameters
indexIndex of item to be removed.
void SSQLE.CommandsHistory.RemoveFirst ( )
private

Removes the oldest command from the history. Has O(maxItems) complexity. See CommandsHistory for more information.

Member Data Documentation

readonly IList<string> SSQLE.CommandsHistory.commands = new List<string>()
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.

readonly int SSQLE.CommandsHistory.maxItems
private

Property Documentation

string SSQLE.CommandsHistory.this[int index]
getset

Indexer for the list.

Parameters
indexIndex in the list.
Returns
Command at index .

The documentation for this class was generated from the following file: