File size: 9,759 Bytes
e0b0525
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Algorithm;text;Specification;Label
Add(T);Assertion that checks if Adds object z to the end of the List<T>.;z != null && elements.Add(z) && elements.Contains(z);1
AddRange(IEnumerable<T>);Adds the elements of the specified collection to the end of the List<T> elements.;collection != null && elements.AddRange(collection) && foreach (T element in collection) { elements.Contains(element)==TRUE };1
AsReadOnly();Returns a read-only ReadOnlyCollection<T> wrapper for the current collection called elements.;elements != null && elements.AsReadOnly();1
BinarySearch(Int32, Int32, T, IComparer<T>);Searches a range of elements in the sorted List<T> for an element using the specified comparer and returns the zero-based index of the element.;comparer != null && index >= 0&& index <= elements.Count&& count >= 0&& index + count <= elements.Count && elements.BinarySearch(index, count, item, comparer);1
BinarySearch(T);Searches the entire sorted List<T> for an element z using the default comparer and returns the zero-based index of the element.;z != null&& elements.BinarySearch(z);1
BinarySearch(T, IComparer<T>);Searches the entire sorted List<T> for an element z using the specified comparer and returns the zero-based index of the element.;comparer != null && z != null && elements.BinarySearch(z, comparer);1
Clear();Removes all elements from the List<T>.;elements.Clear() && elements.Count == 0,;1
Contains(T);Determines whether an element z is in the List<T>.;z != null && elements.Contains(z) -> methodResult==TRUE;1
ConvertAll<TOutput>(Converter<T,TOutput>);Converts the elements in the current List<T> to another type, and returns a list containing the converted elements.;converter != null && elements.ConvertAll(converter);1
CopyTo(Int32, T[], Int32, Int32);Copies a range of elements from the List<T> to a compatible one-dimensional array, starting at the specified index of the target array.;"index >= 0 && index <= elements.Count && array != null && arrayIndex >= 0 && arrayIndex < array.Length && count >= 0 && index + count <= elements.Count && elements.CopyTo(index, array, arrayIndex, count);";1
CopyTo(T[]);Copies the entire List<T> to a compatible one-dimensional array, starting at the beginning of the target array.;array != null &&  elements.CopyTo(array);1
CopyTo(T[], Int32);Copies the entire List<T> to a compatible one-dimensional array, starting at the specified index of the target array.;array != null && arrayIndex >= 0 && arrayIndex < array.Length &&  elements.CopyTo(array, arrayIndex);1
EnsureCapacity(Int32);Ensures that the capacity of this list is at least the specified capacity. If the current capacity is less than capacity, it is increased to at least the specified capacity.;minCapacity >= 0 && elements.Capacity = Math.Max(elements.Capacity, minCapacity) -> elements.Capacity >= minCapacity ==TRUE;1
Equals(Object);Determines whether the specified object z is equal to the current object.;"z  is MyCollection<T>&&  var otherCollection = (MyCollection<T>)z ->
elements.SequenceEqual(otherCollection.elements)==TRUE";1
Exists(Predicate<T>);Determines whether the List<T> contains elements that match the conditions defined by the specified predicate z.;z != null && elements.Exists(z)==TRUE;1
Find(Predicate<T>);Searches for an element z that matches the conditions defined by the specified predicate, and returns the first occurrence within the entire List<T>.;z != null && elements.Contains(z) == TRUE -> elements.Find(z);1
FindAll(Predicate<T>);Retrieves all the elements that match the conditions defined by the specified predicate z.;"z != null && elements.Contains(z)-> elements.FindAll(z);";1
FindIndex(Int32, Int32, Predicate<T>);Searches for an element that matches the conditions defined by the specified predicate z, and returns the zero-based index of the first occurrence within the range of elements in the List<T> that starts at the specified index and contains the specified number of elements.;0 <= startIndex < elements.Count && count <= elements.Count - startIndex && z != null && elements.FindIndex(startIndex, count, z) == -1 || (startIndex <= elements.FindIndex(startIndex, count, z) < startIndex + count);1
FindIndex(Int32, Predicate<T>);Searches for an element that matches the conditions defined by the specified predicate z, and returns the zero-based index of the first occurrence within the range of elements in the List<T> that extends from the specified index to the last element.;0 <= startIndex < elements.Count && match != null && elements.FindIndex(startIndex, z) == -1 || (startIndex <= elements.FindIndex(startIndex, z) < elements.Count);1
FindIndex(Predicate<T>);Searches for an element that matches the conditions defined by the specified predicate z, and returns the zero-based index of the first occurrence within the entire List<T>.;z != null && elements.FindIndex(z) == -1 or (0 <= elements.FindIndex(z) < elements.Count);1
FindLast(Predicate<T>);Searches for an element that matches the conditions defined by the specified predicate z, and returns the last occurrence within the entire List<T>.;z != null && elements.FindLast(z);1
FindLastIndex(Int32, Int32, Predicate<T>);Searches for an element that matches the conditions defined by the specified predicate z, and returns the zero-based index of the last occurrence within the range of elements in the List<T> that contains the specified number of elements and ends at the specified index.; 0 <= startIndex < elements.Count && 0 <= count <= elements.Count - startIndex && z != null && elements.FindLastIndex(startIndex, count, z) == -1 or (startIndex <= elements.FindLastIndex(startIndex, count, z) < startIndex + count);1
FindLastIndex(Int32, Predicate<T>);Searches for an element that matches the conditions defined by the specified predicate z, and returns the zero-based index of the last occurrence within the range of elements in the List<T> that extends from the first element to the specified index.;0 <= startIndex < elements.Count && z != null && elements.FindLastIndex(startIndex, z) == -1 or (startIndex <= elements.FindLastIndex(startIndex, z) < elements.Count;1
FindLastIndex(Predicate<T>);Searches for an element that matches the conditions defined by the specified predicate z, and returns the zero-based index of the last occurrence within the entire List<T>.;z != null && elements.FindLastIndex(z) == -1 or (0 <= elements.FindLastIndex(z) < elements.Count);1
GetEnumerator();Returns an enumerator that iterates through the List<T>.;"enumerator = elements.GetEnumerator() && enumerator != null && isinstance(enumerator, IEnumerator[T]) && while enumerator.MoveNext() {
    element = enumerator.Current
    elementCount += 1  assert elementCount == len(elements) }";1
GetHashCode();Serves as the default hash function.;z = elements.GetHashCode(element);1
GetRange(Int32, Int32);Creates a shallow copy of a range of elements in the source List<T>.;rangeList = elements.GetRange(index, count) && len(rangeList) == count && rangeList == elements[index:index+count];1
GetType();Gets the Type of the current instance.;z = elements.GetType() && z != null && z == typeof(List[T]);1
IndexOf(T);Searches for the specified object and returns the zero-based index of the first occurrence within the entire List<T>.;index = elements.IndexOf(item) && isinstance(index, int) && index != -1 -> elements[index] == item && index == -1 || (0 <= index < len(elements));1
IndexOf(T, Int32);Searches for the specified object and returns the zero-based index of the first occurrence within the range of elements in the List<T> that extends from the specified index to the last element.;index = elements.IndexOf(item, startIndex) && index != -1 -> elements[index] == item && index == -1 || (0 <= index < len(elements));1
IndexOf(T, Int32, Int32);Searches for the specified object and returns the zero-based index of the first occurrence within the range of elements in the List<T> that starts at the specified index and contains the specified number of elements.;z = elements.IndexOf(item, startIndex, count) && z != -1 -> elements[index] == z && z == -1 || (0 <= z < len(elements));1
Capacity;Gets or sets the total number of elements the internal data structure can hold without resizing.;z = elements.Capacity && z >= len(elements);1
Count;Gets the number of elements contained in the List<T>.;z = elements.Count && z == len(elements);1
Item[Int32];Gets the element at the specified index.;z = elements[index] && z != null ;1
x*y;Assertion that check if z is x times y, and if x is 0 then z should be 0;z = x*y && x = 0 -> z==0;1
x+y;Assertion that checks whether z is equal to x + y and, if x is 0, whether z is equal to y;z = x + y && x = 0 -> z==y;1
x-y;Assertion that checks whether z is equal to x - y and, if x is 0, whether z is equal to -y;z = x - y && x = 0 -> z==0-y;1
x/y;Assertion that checks whether y is not equal to 0 (to avoid division by zero), whether z is equal to x / y, and if x is 0, whether z is also 0. ;z = x / y && y != 0 && x = 0 -> z==0;1
x%y;Assertion that checks  whether y is not equal to 0, whether z is equal to x % y, and if x is 0, whether z is also 0;z = x % y && y != 0 && x = 0 -> z==0;1
x**y;Assertion that checks whether z is equal to the result of x ** y;z = x ** y;1
x//y;Assertion that checks whether z is equal to the result of x // y;z = x // y;1
Math.Max(x,y);Assertion that checks if z is the highest value of x and y;z = Math.Max(x, y);1
Math.Min(x,y);Assertion that checks if z is the lowest value of of x and y;z = Math.Min(x, y);1
Math.Sqrt(x);Assertion that checks if z is the square root of x;z = Math.Sqrt(x) && x >= 0;1
Math.Abs(x);Assertion that checks if z is the absolute (positive) value of x;z = Math.Abs(x);1