comparison dwt/dwthelper/array.d @ 99:d32621bf0f90

Ported dwt.dnd.DropTarget
author Jacob Carlborg <doob@me.com>
date Wed, 31 Dec 2008 13:16:18 +0100
parents 62202ce0039f
children 2e671fa40eec
comparison
equal deleted inserted replaced
98:5acb3346c926 99:d32621bf0f90
24 * element = element to be appended to this list 24 * element = element to be appended to this list
25 * 25 *
26 * Returns: the modified array 26 * Returns: the modified array
27 * 27 *
28 * Throws: AssertException if the length of the array is 0 28 * Throws: AssertException if the length of the array is 0
29 * Throws: AssertException if the element is null
30 */ 29 */
31 T[] add (T) (ref T[] arr, T element) 30 T[] add (T) (ref T[] arr, T element)
32 in 31 in
33 { 32 {
34 assert(arr.length > 0); 33 assert(arr.length > 0);
46 * element = element to be appended to this list 45 * element = element to be appended to this list
47 * 46 *
48 * Returns: the modified array 47 * Returns: the modified array
49 * 48 *
50 * Throws: AssertException if the length of the array is 0 49 * Throws: AssertException if the length of the array is 0
51 * Throws: AssertException if the element is null
52 */ 50 */
53 alias add addElement; 51 alias add addElement;
54 52
55 /** 53 /**
56 * Gets the element at the specified index 54 * Gets the element at the specified index
58 * Params: 56 * Params:
59 * arr = the array to get the element from 57 * arr = the array to get the element from
60 * index = the index of the element to get 58 * index = the index of the element to get
61 * 59 *
62 * Returns: the element at the specified index 60 * Returns: the element at the specified index
63 */ 61 *
64 T elementAt (T) (T[] arr, int index) 62 * Throws: AssertException if the length of the array is 0
65 in 63 * AssertException if the $(D_CODE index) is greater than the length of the array
66 { 64 */
67 assert(arr.length > 0); 65 T elementAt (T) (T[] arr, size_t index)
68 assert(index > -1 && index < arr.length); 66 in
67 {
68 assert(arr.length > 0);
69 assert(index < arr.length);
69 } 70 }
70 body 71 body
71 { 72 {
72 return arr[index]; 73 return arr[index];
73 } 74 }
75
76 /**
77 * Gets the element at the specified position in the array
78 *
79 * Params:
80 * arr = the array to get the element from
81 * index = the index of the element to get
82 *
83 * Returns: the element at the specified position
84 *
85 * Throws: AssertException if the length of the array is 0
86 * AssertException if the $(D_CODE index) is greater than the length of the array
87 */
88 alias elementAt get;
74 89
75 /** 90 /**
76 * Returns the number of elements in the specified array. 91 * Returns the number of elements in the specified array.
77 * 92 *
78 * Params: 93 * Params:
95 * index = the index of the element to be removed 110 * index = the index of the element to be removed
96 * 111 *
97 * Returns: the element that was removed or $(D_CODE null) 112 * Returns: the element that was removed or $(D_CODE null)
98 * 113 *
99 * Throws: AssertException if the length of the array is 0 114 * Throws: AssertException if the length of the array is 0
100 * Throws: AssertException if the $(D_CODE index) argument is 115 * AssertException if the $(D_CODE index) argument is
101 * negative or not less than the length of this array. 116 * negative or not less than the length of this array.
102 */ 117 */
103 T remove (T) (ref T[] arr, int index) 118 T remove (T) (ref T[] arr, int index)
104 in 119 in
105 { 120 {