You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+65Lines changed: 65 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -103,3 +103,68 @@ const mySet2 = new HashSet([1, 2, 3]); // creates a HashSet containing the eleme
103
103
<td><code>equals(obj)</code></td><td>Returns <code>true</code> if the value of <code>obj</code> is equal to the value of this instance.</td>
104
104
</tr>
105
105
</table>
106
+
107
+
## ArrayList
108
+
109
+
[ArrayList.js](src/ArrayList.js) implements an dynamically-sized list with a <code>hashCode</code> and <code>equals</code> method. <br>
110
+
Note that <code>ArrayList</code> instances are iterable, so <code>[...myArrayList]</code> will return an array containing the elements in the <code>ArrayList</code> (in order).
111
+
112
+
### Constructor
113
+
The constructor accepts an optional iterable object to use to fill the list initially. If not specified, an empty <code>ArrayList</code> is constructed.
114
+
115
+
```
116
+
const myList = new ArrayList(); // creates an empty ArrayList
117
+
const myList2 = new ArrayList([1, 2, 3]); // creates an ArrayList containing the numbers 1, 2, 3
118
+
```
119
+
120
+
### Instance Methods
121
+
<table>
122
+
<tr>
123
+
<th>Method Signature</th><th>Description</th>
124
+
</tr>
125
+
<tr>
126
+
<td><code>add(...elems)</code></td><td>Adds all of the arguments passed in to the <code>ArrayList</code>.</td>
127
+
</tr>
128
+
<tr>
129
+
<td><code>addAll(obj)</code></td><td>Adds all the elements of the iterable <code>obj</code> to the <code>ArrayList</code>.</td>
130
+
</tr>
131
+
<tr>
132
+
<td><code>removeAtIndex(idx)</code></td><td>Removes the element at the specified index.</td>
133
+
</tr>
134
+
<tr>
135
+
<td><code>get(idx)</code></td><td>Returns the element at the specified index.</td>
136
+
</tr>
137
+
<tr>
138
+
<td><code>addAtIndex(idx, ...elems)</code></td>
139
+
<td>Adds the given elements to the <code>ArrayList</code> starting at the specified index.</td>
140
+
</tr>
141
+
<tr>
142
+
<td><code>set(idx, elem)</code></td><td>Sets the element at the specified index to be <code>elem</code>.</td>
143
+
</tr>
144
+
<tr>
145
+
<td><code>removeIf(predicate)</code></td>
146
+
<td>Removes all elements in the <code>ArrayList</code> that match a predicate (that accepts an element as the only parameter and returns <code>true</code> if it should be removed).</td>
147
+
</tr>
148
+
<tr>
149
+
<td><code>remove(obj)</code></td>
150
+
<td>Removes the first occurrence of <code>obj</code> from the <code>ArrayList</code>.</td>
151
+
</tr>
152
+
<tr>
153
+
<td><code>indexOf(obj)</code></td>
154
+
<td>Returns the first index at which <code>obj</code> is found in the <code>ArrayList</code>.</td>
155
+
</tr>
156
+
<tr>
157
+
<td><code>size()</code></td>
158
+
<td>Returns the number of elements in the <code>ArrayList</code>.</td>
159
+
</tr>
160
+
<tr>
161
+
<td><code>isEmpty()</code></td>
162
+
<td>Returns <code>true</code> if there are no elements in the <code>ArrayList</code>.</td>
163
+
</tr>
164
+
<tr>
165
+
<td><code>hashCode()</code></td><td>Returns an integer hash code for this instance.</td>
166
+
</tr>
167
+
<tr>
168
+
<td><code>equals(obj)</code></td><td>Returns <code>true</code> if the value of <code>obj</code> is equal to the value of this instance.</td>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5
+
6
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7
+
8
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
0 commit comments