File: Arrays.java

package info (click to toggle)
bouncycastle 1.44%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 25,148 kB
  • ctags: 29,306
  • sloc: java: 277,890; xml: 1,881; sh: 974; makefile: 68
file content (81 lines) | stat: -rw-r--r-- 1,576 bytes parent folder | download | duplicates (5)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package java.util;

public class Arrays
{

    private Arrays() {}
    
    public static boolean equals(byte[] a, byte[] a2) {
        if (a==a2)
            return true;
        if (a==null || a2==null)
            return false;

        int length = a.length;
        if (a2.length != length)
            return false;

        for (int i=0; i<length; i++)
            if (a[i] != a2[i])
                return false;

        return true;
    }
    public static List asList(Object[] a) {
    return new ArrayList(a);
    }

    private static class ArrayList extends AbstractList implements java.io.Serializable
    {
    private Object[] a;

    ArrayList(Object[] array)
    {
        a = array;
    }

    public int size()
    {
        return a.length;
    }

    public Object[] toArray()
    {
        return (Object[]) a.clone();
    }

    public Object get(int index)
    {
        return a[index];
    }

    public Object set(int index, Object element)
    {
        Object oldValue = a[index];
        a[index] = element;
        return oldValue;
    }

        public int indexOf(Object o)
    {
            if (o==null)
        {
                for (int i=0; i<a.length; i++)
                    if (a[i]==null)
                        return i;
            }
        else
        {
                for (int i=0; i<a.length; i++)
                    if (o.equals(a[i]))
                        return i;
            }
            return -1;
        }

        public boolean contains(Object o)
    {
            return indexOf(o) != -1;
        }
    }
}