Collection Classes - slide 20 : 36 |
Operation | Collection<T> | List<T> | LinkedList<T> |
this[i] | O(1) | O(1) | - |
Count | O(1) | O(1) | O(1) |
Add(e) | O(1) or O(n) | O(1) or O(n) | O(1) |
Insert(i,e) | O(n) | O(n) | - |
Remove(e) | O(n) | O(n) | O(n) |
IndexOf(e) | O(n) | O(n) | - |
Contains(e) | O(n) | O(n) | O(n) |
BinarySearch(e) | - | O(log n) | - |
Sort() | - | O(n log n) or O(n2) | - |
AddBefore(lln) | - | - | O(1) |
AddAfter(lln,e) | - | - | O(1) |
Remove(lln) | - | - | O(1) |
RemoveFirst() | - | - | O(1) |
RemoveLast() | - | - | O(1) |