Interface IXifoStructure<T>
An Abstract Data Type modelling a generic XIFO structure: either a LIFO (such as a XStack<T>), or a FIFO (such as a XQueue<T>).
Namespace: MoreStructures.XifoStructures
Assembly: MoreStructures.dll
Syntax
public interface IXifoStructure<T>
Type Parameters
Name | Description |
---|---|
T | The type of items of the data structure. |
Remarks
This interface is implemented by adapters for standard data structures present in the framework, such as
XStack<T> and XQueue<T>.
The advantage of using this interface is that the order of insertion and extraction of the items of the structure
can be changed in the code of the client using the data structure without changing the code itself.
Properties
| Improve this Doc View SourceCount
Returns the number of items in this data structure.
Declaration
int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 | A non-negative value. |
Methods
| Improve this Doc View SourcePop()
Extracts the first available item from this data structure.
Declaration
T Pop()
Returns
Type | Description |
---|---|
T | An item of the data structure, of type |
Remarks
Extraction is done in a way to minimize the cost of the operation.
For example extraction from a stack is done from the top of the stack, since it can be accessed in O(1) time.
Extraction from a queue is done at the beginning of the queue, since it can be modified in O(1) time.
Push(T)
Inserts the provided item
into this data structure.
Declaration
void Push(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to be inserted. |
Remarks
Insertion is done in a way to minimize the cost of the operation.
For example insertion into a stack is done on top of the stack, since prepending is a O(1) operation.
Insertion into a queue is done at the end of the queue instead, since appending is the O(1) way of inserting.