Collection |
Add |
Insert |
Remove |
Item |
Sort |
Find |
List<t> |
If the collection resets size, it is O (1) or o (n) |
O (N) |
O (N) |
O (1) |
O (n log n), worst case O (n^2) |
|
Stack<t> |
Push (), if the stack must be reset size, is O (1) or o (n) |
N/A |
Pop,o (1) |
N/A |
N/A |
N/A |
Queue<t> |
Enqueue (), if the queue must be reset size, is O (1) or o (n) |
N/A |
Dequeue,o (1) |
N/A |
N/A |
N/A |
Hasset<t> |
If the size must be reset, it is O (1) or o (n) |
Add (), O (1) or o (n) |
O (1) |
N/A |
N/A |
N/A |
Sortedset<t> |
If the size must be reset, it is O (1) or o (n) |
Add (), O (1) or o (n) |
O (1) |
N/A |
N/A |
N/A |
Linkedlist<t> |
AddLast (), O (1) |
Addafter (), O (1) |
O (1) |
N/A |
N/A |
O (N) |
Dictionary<tkey,tvalue) |
O (1) or o (n) |
N/A |
O (1) |
O (1) |
N/A |
N/A |
Sorteddictionary<tkey,tvalue) |
O (log n) |
N/A |
O (log n) |
O (log n) |
N/A |
N/A |
Sortedlist<tkey,tvalue) |
Unordered data is O (n); If the size must be reset to O (n), the tail of the list is O (log n) |
N/A |
O (N) |
Read/write is O (log n); If the key is in the list, O (log n),if the key is not in the list O (n) |
N/A |
N/A |
Note:
O (1) indicates that the time required for this operation is constant regardless of the number of data items in the collection.
O (n) indicates that the time required to perform an operation on the collection is n in the worst case , indicating a linear increase as the element increases.
O (log n) indicates that the time required for the operation increases with the increase of the elements in the collection, but the increment time required for each element is not linear, but is a pair of curves.
. NET Collection Type performance analysis