1 10 package org.python.core; 11 12 import java.util.Collection ; 13 import java.util.Iterator ; 14 import java.util.List ; 15 import java.util.ListIterator ; 16 import java.util.Arrays ; 17 18 19 25 public abstract class PySequenceList extends PySequence implements List { 26 27 protected PyObjectList list; 28 29 public PySequenceList() { 30 list = new PyObjectList(); 31 } 32 33 protected PySequenceList(PyType type) { 34 super(type); 35 list = new PyObjectList(); 36 } 37 38 42 public PySequenceList(PyObject[] elements) { 43 list = new PyObjectList(elements); 44 } 45 46 public PySequenceList(Collection c) { 47 list = new PyObjectList(c); 48 } 49 50 public void add(int index, Object element) { 51 list.add(index, element); 52 } 53 public boolean add(Object o) { 54 return list.add(o); 55 } 56 public boolean addAll(int index, Collection c) { 57 return list.addAll(index, c); 58 } 59 public boolean addAll(Collection c) { 60 return list.addAll(c); 61 } 62 public void clear() { 63 list.clear(); 64 } 65 public boolean contains(Object o) { 66 return list.contains(o); 67 } 68 public boolean containsAll(Collection c) { 69 return list.containsAll(c); 70 } 71 public Object get(int index) { 72 return list.get(index); 73 } 74 public int indexOf(Object o) { 75 return list.indexOf(o); 76 } 77 public boolean isEmpty() { 78 return list.isEmpty(); 79 } 80 public Iterator iterator() { 81 return list.iterator(); 82 } 83 public int lastIndexOf(Object o) { 84 return list.lastIndexOf(o); 85 } 86 public ListIterator listIterator() { 87 return list.listIterator(); 88 } 89 public ListIterator listIterator(int index) { 90 return list.listIterator(index); 91 } 92 public void pyadd(int index, PyObject element) { 93 list.pyadd(index, element); 94 } 95 public PyObject pyget(int index) { 96 return list.pyget(index); 97 } 98 public PyObject pyset(int index, PyObject element) { 99 return list.pyset(index, element); 100 } 101 public Object remove(int index) { 102 return list.remove(index); 103 } 104 public void remove(int start, int stop) { 105 list.remove(start, stop); 106 } 107 public boolean remove(Object o) { 108 return list.remove(o); 109 } 110 public boolean removeAll(Collection c) { 111 return list.removeAll(c); 112 } 113 public boolean retainAll(Collection c) { 114 return list.retainAll(c); 115 } 116 public Object set(int index, Object element) { 117 return list.set(index, element); 118 } 119 public int size() { 120 return list.size(); 121 } 122 public List subList(int fromIndex, int toIndex) { 123 return list.subList(fromIndex, toIndex); 124 } 125 public Object [] toArray() { 126 return list.toArray(); 127 } 128 public Object [] toArray(Object [] a) { 129 return list.toArray(a); 130 } 131 public String toString() { 132 return list.toString(); 133 } 134 public boolean pyadd(PyObject o) { 135 return list.pyadd(o); 136 } 137 138 public boolean equals(Object o) { 139 if(o instanceof PySequenceList) { 140 return list.equals(((PySequenceList)o).list); 141 } else if (o instanceof List ) { 142 return o.equals(this); 143 } else return false; 144 } 145 146 public int hashCode() { 147 return list.hashCode(); 148 } 149 150 157 163 public PyObject[] getArray() { 164 return list.getArray(); 165 } 166 } 167 | Popular Tags |