View | Details | Raw Unified | Return to bug 63805
Collapse All | Expand All

(-)src/java/org/apache/poi/util/IntList.java (-50 / +36 lines)
Lines 17-22 Link Here
17
17
18
package org.apache.poi.util;
18
package org.apache.poi.util;
19
19
20
import java.util.Arrays;
21
20
/**
22
/**
21
 * A List of int's; as full an implementation of the java.util.List
23
 * A List of int's; as full an implementation of the java.util.List
22
 * interface as possible, with an eye toward minimal creation of
24
 * interface as possible, with an eye toward minimal creation of
Lines 100-106 Link Here
100
        }
102
        }
101
        else
103
        else
102
        {
104
        {
103
104
            // index < limit -- insert into the middle
105
            // index < limit -- insert into the middle
105
            if (_limit == _array.length)
106
            if (_limit == _array.length)
106
            {
107
            {
Lines 229-244 Link Here
229
230
230
    public boolean contains(final int o)
231
    public boolean contains(final int o)
231
    {
232
    {
232
        boolean rval = false;
233
        for (int j = 0; j < _limit; j++)
233
234
        for (int j = 0; !rval && (j < _limit); j++)
235
        {
234
        {
236
            if (_array[ j ] == o)
235
            if (_array[ j ] == o)
237
            {
236
            {
238
                rval = true;
237
                return true;
239
            }
238
            }
240
        }
239
        }
241
        return rval;
240
        return false;
242
    }
241
    }
243
242
244
    /**
243
    /**
Lines 253-271 Link Here
253
252
254
    public boolean containsAll(final IntList c)
253
    public boolean containsAll(final IntList c)
255
    {
254
    {
256
        boolean rval = true;
257
258
        if (this != c)
255
        if (this != c)
259
        {
256
        {
260
            for (int j = 0; rval && (j < c._limit); j++)
257
            for (int j = 0; j < c._limit; j++)
261
            {
258
            {
262
                if (!contains(c._array[ j ]))
259
                if (!contains(c._array[ j ]))
263
                {
260
                {
264
                    rval = false;
261
                    return false;
265
                }
262
                }
266
            }
263
            }
267
        }
264
        }
268
        return rval;
265
        return true;
269
    }
266
    }
270
267
271
    /**
268
    /**
Lines 286-309 Link Here
286
283
287
    public boolean equals(final Object o)
284
    public boolean equals(final Object o)
288
    {
285
    {
289
        boolean rval = this == o;
286
        if (o == this) {
287
            return true;
288
        }
289
        
290
        if (o.getClass()!=this.getClass()) {
291
            return false;
292
        }
290
293
291
        if (!rval && (o != null) && (o.getClass() == this.getClass()))
294
        IntList other = ( IntList ) o;
292
        {
293
            IntList other = ( IntList ) o;
294
295
295
            if (other._limit == _limit)
296
        if (other._limit != _limit) {
296
            {
297
            return false;
297
298
        }
298
                // assume match
299
        
299
                rval = true;
300
        for (int i=0; i< _limit; i++) {
300
                for (int j = 0; rval && (j < _limit); j++)
301
            if (other._array[i] != _array[i]) {
301
                {
302
                return false;
302
                    rval = _array[ j ] == other._array[ j ];
303
                }
304
            }
303
            }
305
        }
304
        }
306
        return rval;
305
        
306
        return true;
307
    }
307
    }
308
308
309
    /**
309
    /**
Lines 374-393 Link Here
374
374
375
    public int indexOf(final int o)
375
    public int indexOf(final int o)
376
    {
376
    {
377
        int rval = 0;
377
        for (int i=0; i<_limit; i++) {
378
378
            if (_array[i] == o) {
379
        for (; rval < _limit; rval++)
379
                return i;
380
        {
381
            if (o == _array[ rval ])
382
            {
383
                break;
384
            }
380
            }
385
        }
381
        }
386
        if (rval == _limit)
382
        return -1;
387
        {
388
            rval = -1;   // didn't find it
389
        }
390
        return rval;
391
    }
383
    }
392
384
393
    /**
385
    /**
Lines 416-431 Link Here
416
408
417
    public int lastIndexOf(final int o)
409
    public int lastIndexOf(final int o)
418
    {
410
    {
419
        int rval = _limit - 1;
411
        for (int i=_limit-1; i>=0; i--) {
420
412
            if (_array[i] == o) {
421
        for (; rval >= 0; rval--)
413
                return i;
422
        {
423
            if (o == _array[ rval ])
424
            {
425
                break;
426
            }
414
            }
427
        }
415
        }
428
        return rval;
416
        return -1;
429
    }
417
    }
430
418
431
    /**
419
    /**
Lines 469-477 Link Here
469
457
470
    public boolean removeValue(final int o)
458
    public boolean removeValue(final int o)
471
    {
459
    {
472
        boolean rval = false;
460
        for (int j = 0; j < _limit; j++)
473
474
        for (int j = 0; !rval && (j < _limit); j++)
475
        {
461
        {
476
            if (o == _array[ j ])
462
            if (o == _array[ j ])
477
            {
463
            {
Lines 479-488 Link Here
479
                    System.arraycopy(_array, j + 1, _array, j, _limit - j);
465
                    System.arraycopy(_array, j + 1, _array, j, _limit - j);
480
                }
466
                }
481
                _limit--;
467
                _limit--;
482
                rval = true;
468
                return true;
483
            }
469
            }
484
        }
470
        }
485
        return rval;
471
        return false;
486
    }
472
    }
487
473
488
    /**
474
    /**

Return to bug 63805