| 227 | |
| 228 | // Remove all instances of a particular value and return the count removed. |
| 229 | public int removeValues(String value) { |
| 230 | int ii = 0; |
| 231 | if (value == null) { |
| 232 | for (int i = 0; i < count; i++) { |
| 233 | if (data[i] != null) { |
| 234 | data[ii++] = data[i]; |
| 235 | } |
| 236 | } |
| 237 | } else { |
| 238 | for (int i = 0; i < count; i++) { |
| 239 | if (!value.equals(data[i])) { |
| 240 | data[ii++] = data[i]; |
| 241 | } |
| 242 | } |
| 243 | } |
| 244 | int removed = count - ii; |
| 245 | count = ii; |
| 246 | return removed; |
| 247 | } |
| 248 | |
| 249 | |
| 250 | // replace the first value that matches, return the index that was replaced |