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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
package java.util;
/**
* Title:
* Description:
* Copyright: Copyright (c) 2001
* Company:
* @version 1.0
*/
public class Sublist extends AbstractList
{
AbstractList m_al=null;
int m_fromIndex=0;
int m_toIndex=0;
int size=0;
public Sublist(AbstractList ali,int fromIndex,int toIndex)
{
m_al=ali;
m_toIndex=toIndex;
m_fromIndex=fromIndex;
size = size();
}
public Object set(int index,Object o)
{
if (index < size)
{
o = m_al.set(index+m_fromIndex,o);
if (o != null)
{
size++;
m_toIndex++;
}
return o;
}
else throw new IndexOutOfBoundsException();
}
public Object get(int index) throws IndexOutOfBoundsException
{
if (index < size) return m_al.get(index+m_fromIndex);
else throw new IndexOutOfBoundsException();
}
public void add (int index,Object o)
{
if (index <= size)
{
m_al.add(index + m_fromIndex,o);
m_toIndex++;
size++;
}
else throw new IndexOutOfBoundsException();
}
public Object remove(int index,Object o)
{
if (index < size)
{
Object ob = m_al.remove(index + m_fromIndex);
if (ob !=null)
{
m_toIndex--;
size--;
}
return ob;
}
else throw new IndexOutOfBoundsException();
}
public boolean addAll(int index, Collection c)
{
if (index < size)
{
boolean bool = m_al.addAll(index + m_fromIndex,c);
if (bool)
{
int lange = c.size();
m_toIndex = m_toIndex + lange;
size = size + lange;
}
return bool;
}
else throw new IndexOutOfBoundsException();
}
public boolean addAll(Collection c)
{
boolean bool = m_al.addAll(m_toIndex,c);
if (bool)
{
int lange = c.size();
m_toIndex = m_toIndex + lange;
size = size + lange;
}
return bool;
}
public void removeRange (int from,int to)
{
if ((from <= to) && (from <= size) && (to <= size))
{
m_al.removeRange(from,to);
int lange = to - from;
m_toIndex = m_toIndex - lange;
size = size - lange;
}
else
{
if (from > to) throw new IllegalArgumentException();
else throw new IndexOutOfBoundsException();
}
}
public int size()
{
return (m_toIndex - m_fromIndex);
}
}
|