KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > python > core > PyList


1 // Copyright (c) Corporation for National Research Initiatives
2

3 // Implementation of the standard Python list objects
4

5 package org.python.core;
6 import java.util.Collection JavaDoc;
7 import java.util.Iterator JavaDoc;
8 import java.util.List JavaDoc;
9 import java.util.Vector JavaDoc;
10
11 /**
12  * A builtin python list.
13  */

14
15 public class PyList extends PySequenceList {
16
17     public static void classDictInit(PyObject dict) throws PyIgnoreMethodTag {}
18
19     /* type info */
20
21     public static final String JavaDoc exposed_name="list";
22
23     public static final Class JavaDoc exposed_base=PyObject.class;
24
25     public static void typeSetup(PyObject dict,PyType.Newstyle marker) {
26         class exposed___ne__ extends PyBuiltinFunctionNarrow {
27
28             private PyList self;
29
30             public PyObject getSelf() {
31                 return self;
32             }
33
34             exposed___ne__(PyList self,PyBuiltinFunction.Info info) {
35                 super(info);
36                 this.self=self;
37             }
38
39             public PyBuiltinFunction makeBound(PyObject self) {
40                 return new exposed___ne__((PyList)self,info);
41             }
42
43             public PyObject __call__(PyObject arg0) {
44                 PyObject ret=self.seq___ne__(arg0);
45                 if (ret==null)
46                     return Py.NotImplemented;
47                 return ret;
48             }
49
50             public PyObject inst_call(PyObject gself,PyObject arg0) {
51                 PyList self=(PyList)gself;
52                 PyObject ret=self.seq___ne__(arg0);
53                 if (ret==null)
54                     return Py.NotImplemented;
55                 return ret;
56             }
57
58         }
59         dict.__setitem__("__ne__",new PyMethodDescr("__ne__",PyList.class,1,1,new exposed___ne__(null,null)));
60         class exposed___eq__ extends PyBuiltinFunctionNarrow {
61
62             private PyList self;
63
64             public PyObject getSelf() {
65                 return self;
66             }
67
68             exposed___eq__(PyList self,PyBuiltinFunction.Info info) {
69                 super(info);
70                 this.self=self;
71             }
72
73             public PyBuiltinFunction makeBound(PyObject self) {
74                 return new exposed___eq__((PyList)self,info);
75             }
76
77             public PyObject __call__(PyObject arg0) {
78                 PyObject ret=self.seq___eq__(arg0);
79                 if (ret==null)
80                     return Py.NotImplemented;
81                 return ret;
82             }
83
84             public PyObject inst_call(PyObject gself,PyObject arg0) {
85                 PyList self=(PyList)gself;
86                 PyObject ret=self.seq___eq__(arg0);
87                 if (ret==null)
88                     return Py.NotImplemented;
89                 return ret;
90             }
91
92         }
93         dict.__setitem__("__eq__",new PyMethodDescr("__eq__",PyList.class,1,1,new exposed___eq__(null,null)));
94         class exposed___getitem__ extends PyBuiltinFunctionNarrow {
95
96             private PyList self;
97
98             public PyObject getSelf() {
99                 return self;
100             }
101
102             exposed___getitem__(PyList self,PyBuiltinFunction.Info info) {
103                 super(info);
104                 this.self=self;
105             }
106
107             public PyBuiltinFunction makeBound(PyObject self) {
108                 return new exposed___getitem__((PyList)self,info);
109             }
110
111             public PyObject __call__(PyObject arg0) {
112                 PyObject ret=self.seq___finditem__(arg0);
113                 if (ret==null) {
114                     throw Py.IndexError("index out of range: "+arg0);
115                 }
116                 return ret;
117             }
118
119             public PyObject inst_call(PyObject gself,PyObject arg0) {
120                 PyList self=(PyList)gself;
121                 PyObject ret=self.seq___finditem__(arg0);
122                 if (ret==null) {
123                     throw Py.IndexError("index out of range: "+arg0);
124                 }
125                 return ret;
126             }
127
128         }
129         dict.__setitem__("__getitem__",new PyMethodDescr("__getitem__",PyList.class,1,1,new exposed___getitem__(null,null)));
130         class exposed___contains__ extends PyBuiltinFunctionNarrow {
131
132             private PyList self;
133
134             public PyObject getSelf() {
135                 return self;
136             }
137
138             exposed___contains__(PyList self,PyBuiltinFunction.Info info) {
139                 super(info);
140                 this.self=self;
141             }
142
143             public PyBuiltinFunction makeBound(PyObject self) {
144                 return new exposed___contains__((PyList)self,info);
145             }
146
147             public PyObject __call__(PyObject arg0) {
148                 return Py.newBoolean(self.object___contains__(arg0));
149             }
150
151             public PyObject inst_call(PyObject gself,PyObject arg0) {
152                 PyList self=(PyList)gself;
153                 return Py.newBoolean(self.object___contains__(arg0));
154             }
155
156         }
157         dict.__setitem__("__contains__",new PyMethodDescr("__contains__",PyList.class,1,1,new exposed___contains__(null,null)));
158         class exposed___delitem__ extends PyBuiltinFunctionNarrow {
159
160             private PyList self;
161
162             public PyObject getSelf() {
163                 return self;
164             }
165
166             exposed___delitem__(PyList self,PyBuiltinFunction.Info info) {
167                 super(info);
168                 this.self=self;
169             }
170
171             public PyBuiltinFunction makeBound(PyObject self) {
172                 return new exposed___delitem__((PyList)self,info);
173             }
174
175             public PyObject __call__(PyObject arg0) {
176                 self.seq___delitem__(arg0);
177                 return Py.None;
178             }
179
180             public PyObject inst_call(PyObject gself,PyObject arg0) {
181                 PyList self=(PyList)gself;
182                 self.seq___delitem__(arg0);
183                 return Py.None;
184             }
185
186         }
187         dict.__setitem__("__delitem__",new PyMethodDescr("__delitem__",PyList.class,1,1,new exposed___delitem__(null,null)));
188         class exposed___setitem__ extends PyBuiltinFunctionNarrow {
189
190             private PyList self;
191
192             public PyObject getSelf() {
193                 return self;
194             }
195
196             exposed___setitem__(PyList self,PyBuiltinFunction.Info info) {
197                 super(info);
198                 this.self=self;
199             }
200
201             public PyBuiltinFunction makeBound(PyObject self) {
202                 return new exposed___setitem__((PyList)self,info);
203             }
204
205             public PyObject __call__(PyObject arg0,PyObject arg1) {
206                 self.seq___setitem__(arg0,arg1);
207                 return Py.None;
208             }
209
210             public PyObject inst_call(PyObject gself,PyObject arg0,PyObject arg1) {
211                 PyList self=(PyList)gself;
212                 self.seq___setitem__(arg0,arg1);
213                 return Py.None;
214             }
215
216         }
217         dict.__setitem__("__setitem__",new PyMethodDescr("__setitem__",PyList.class,2,2,new exposed___setitem__(null,null)));
218         class exposed___nonzero__ extends PyBuiltinFunctionNarrow {
219
220             private PyList self;
221
222             public PyObject getSelf() {
223                 return self;
224             }
225
226             exposed___nonzero__(PyList self,PyBuiltinFunction.Info info) {
227                 super(info);
228                 this.self=self;
229             }
230
231             public PyBuiltinFunction makeBound(PyObject self) {
232                 return new exposed___nonzero__((PyList)self,info);
233             }
234
235             public PyObject __call__() {
236                 return Py.newBoolean(self.seq___nonzero__());
237             }
238
239             public PyObject inst_call(PyObject gself) {
240                 PyList self=(PyList)gself;
241                 return Py.newBoolean(self.seq___nonzero__());
242             }
243
244         }
245         dict.__setitem__("__nonzero__",new PyMethodDescr("__nonzero__",PyList.class,0,0,new exposed___nonzero__(null,null)));
246         class exposed___getslice__ extends PyBuiltinFunctionNarrow {
247
248             private PyList self;
249
250             public PyObject getSelf() {
251                 return self;
252             }
253
254             exposed___getslice__(PyList self,PyBuiltinFunction.Info info) {
255                 super(info);
256                 this.self=self;
257             }
258
259             public PyBuiltinFunction makeBound(PyObject self) {
260                 return new exposed___getslice__((PyList)self,info);
261             }
262
263             public PyObject __call__(PyObject arg0,PyObject arg1,PyObject arg2) {
264                 return self.seq___getslice__(arg0,arg1,arg2);
265             }
266
267             public PyObject inst_call(PyObject gself,PyObject arg0,PyObject arg1,PyObject arg2) {
268                 PyList self=(PyList)gself;
269                 return self.seq___getslice__(arg0,arg1,arg2);
270             }
271
272         }
273         dict.__setitem__("__getslice__",new PyMethodDescr("__getslice__",PyList.class,3,3,new exposed___getslice__(null,null)));
274         class exposed___delslice__ extends PyBuiltinFunctionNarrow {
275
276             private PyList self;
277
278             public PyObject getSelf() {
279                 return self;
280             }
281
282             exposed___delslice__(PyList self,PyBuiltinFunction.Info info) {
283                 super(info);
284                 this.self=self;
285             }
286
287             public PyBuiltinFunction makeBound(PyObject self) {
288                 return new exposed___delslice__((PyList)self,info);
289             }
290
291             public PyObject __call__(PyObject arg0,PyObject arg1,PyObject arg2) {
292                 self.seq___delslice__(arg0,arg1,arg2);
293                 return Py.None;
294             }
295
296             public PyObject inst_call(PyObject gself,PyObject arg0,PyObject arg1,PyObject arg2) {
297                 PyList self=(PyList)gself;
298                 self.seq___delslice__(arg0,arg1,arg2);
299                 return Py.None;
300             }
301
302         }
303         dict.__setitem__("__delslice__",new PyMethodDescr("__delslice__",PyList.class,3,3,new exposed___delslice__(null,null)));
304         class exposed___setslice__ extends PyBuiltinFunctionNarrow {
305
306             private PyList self;
307
308             public PyObject getSelf() {
309                 return self;
310             }
311
312             exposed___setslice__(PyList self,PyBuiltinFunction.Info info) {
313                 super(info);
314                 this.self=self;
315             }
316
317             public PyBuiltinFunction makeBound(PyObject self) {
318                 return new exposed___setslice__((PyList)self,info);
319             }
320
321             public PyObject __call__(PyObject arg0,PyObject arg1,PyObject arg2,PyObject arg3) {
322                 self.seq___setslice__(arg0,arg1,arg2,arg3);
323                 return Py.None;
324             }
325
326             public PyObject inst_call(PyObject gself,PyObject arg0,PyObject arg1,PyObject arg2,PyObject arg3) {
327                 PyList self=(PyList)gself;
328                 self.seq___setslice__(arg0,arg1,arg2,arg3);
329                 return Py.None;
330             }
331
332         }
333         dict.__setitem__("__setslice__",new PyMethodDescr("__setslice__",PyList.class,4,4,new exposed___setslice__(null,null)));
334         class exposed_append extends PyBuiltinFunctionNarrow {
335
336             private PyList self;
337
338             public PyObject getSelf() {
339                 return self;
340             }
341
342             exposed_append(PyList self,PyBuiltinFunction.Info info) {
343                 super(info);
344                 this.self=self;
345             }
346
347             public PyBuiltinFunction makeBound(PyObject self) {
348                 return new exposed_append((PyList)self,info);
349             }
350
351             public PyObject __call__(PyObject arg0) {
352                 self.list_append(arg0);
353                 return Py.None;
354             }
355
356             public PyObject inst_call(PyObject gself,PyObject arg0) {
357                 PyList self=(PyList)gself;
358                 self.list_append(arg0);
359                 return Py.None;
360             }
361
362         }
363         dict.__setitem__("append",new PyMethodDescr("append",PyList.class,1,1,new exposed_append(null,null)));
364         class exposed_count extends PyBuiltinFunctionNarrow {
365
366             private PyList self;
367
368             public PyObject getSelf() {
369                 return self;
370             }
371
372             exposed_count(PyList self,PyBuiltinFunction.Info info) {
373                 super(info);
374                 this.self=self;
375             }
376
377             public PyBuiltinFunction makeBound(PyObject self) {
378                 return new exposed_count((PyList)self,info);
379             }
380
381             public PyObject __call__(PyObject arg0) {
382                 return Py.newInteger(self.list_count(arg0));
383             }
384
385             public PyObject inst_call(PyObject gself,PyObject arg0) {
386                 PyList self=(PyList)gself;
387                 return Py.newInteger(self.list_count(arg0));
388             }
389
390         }
391         dict.__setitem__("count",new PyMethodDescr("count",PyList.class,1,1,new exposed_count(null,null)));
392         class exposed_extend extends PyBuiltinFunctionNarrow {
393
394             private PyList self;
395
396             public PyObject getSelf() {
397                 return self;
398             }
399
400             exposed_extend(PyList self,PyBuiltinFunction.Info info) {
401                 super(info);
402                 this.self=self;
403             }
404
405             public PyBuiltinFunction makeBound(PyObject self) {
406                 return new exposed_extend((PyList)self,info);
407             }
408
409             public PyObject __call__(PyObject arg0) {
410                 self.list_extend(arg0);
411                 return Py.None;
412             }
413
414             public PyObject inst_call(PyObject gself,PyObject arg0) {
415                 PyList self=(PyList)gself;
416                 self.list_extend(arg0);
417                 return Py.None;
418             }
419
420         }
421         dict.__setitem__("extend",new PyMethodDescr("extend",PyList.class,1,1,new exposed_extend(null,null)));
422         class exposed_index extends PyBuiltinFunctionNarrow {
423
424             private PyList self;
425
426             public PyObject getSelf() {
427                 return self;
428             }
429
430             exposed_index(PyList self,PyBuiltinFunction.Info info) {
431                 super(info);
432                 this.self=self;
433             }
434
435             public PyBuiltinFunction makeBound(PyObject self) {
436                 return new exposed_index((PyList)self,info);
437             }
438
439             public PyObject __call__(PyObject arg0,PyObject arg1,PyObject arg2) {
440                 try {
441                     return Py.newInteger(self.list_index(arg0,arg1.asInt(1),arg2.asInt(2)));
442                 } catch (PyObject.ConversionException e) {
443                     String JavaDoc msg;
444                     switch (e.index) {
445                     case 1:
446                     case 2:
447                         msg="expected an integer";
448                         break;
449                     default:
450                         msg="xxx";
451                     }
452                     throw Py.TypeError(msg);
453                 }
454             }
455
456             public PyObject inst_call(PyObject gself,PyObject arg0,PyObject arg1,PyObject arg2) {
457                 PyList self=(PyList)gself;
458                 try {
459                     return Py.newInteger(self.list_index(arg0,arg1.asInt(1),arg2.asInt(2)));
460                 } catch (PyObject.ConversionException e) {
461                     String JavaDoc msg;
462                     switch (e.index) {
463                     case 1:
464                     case 2:
465                         msg="expected an integer";
466                         break;
467                     default:
468                         msg="xxx";
469                     }
470                     throw Py.TypeError(msg);
471                 }
472             }
473
474             public PyObject __call__(PyObject arg0,PyObject arg1) {
475                 try {
476                     return Py.newInteger(self.list_index(arg0,arg1.asInt(1)));
477                 } catch (PyObject.ConversionException e) {
478                     String JavaDoc msg;
479                     switch (e.index) {
480                     case 1:
481                         msg="expected an integer";
482                         break;
483                     default:
484                         msg="xxx";
485                     }
486                     throw Py.TypeError(msg);
487                 }
488             }
489
490             public PyObject inst_call(PyObject gself,PyObject arg0,PyObject arg1) {
491                 PyList self=(PyList)gself;
492                 try {
493                     return Py.newInteger(self.list_index(arg0,arg1.asInt(1)));
494                 } catch (PyObject.ConversionException e) {
495                     String JavaDoc msg;
496                     switch (e.index) {
497                     case 1:
498                         msg="expected an integer";
499                         break;
500                     default:
501                         msg="xxx";
502                     }
503                     throw Py.TypeError(msg);
504                 }
505             }
506
507             public PyObject __call__(PyObject arg0) {
508                 return Py.newInteger(self.list_index(arg0));
509             }
510
511             public PyObject inst_call(PyObject gself,PyObject arg0) {
512                 PyList self=(PyList)gself;
513                 return Py.newInteger(self.list_index(arg0));
514             }
515
516         }
517         dict.__setitem__("index",new PyMethodDescr("index",PyList.class,1,3,new exposed_index(null,null)));
518
519         class exposed_insert extends PyBuiltinFunctionNarrow {
520
521             private PyList self;
522
523             public PyObject getSelf() {
524                 return self;
525             }
526
527             exposed_insert(PyList self,PyBuiltinFunction.Info info) {
528                 super(info);
529                 this.self=self;
530             }
531
532             public PyBuiltinFunction makeBound(PyObject self) {
533                 return new exposed_insert((PyList)self,info);
534             }
535
536             public PyObject __call__(PyObject arg0,PyObject arg1) {
537                 try {
538                     self.list_insert(arg0.asInt(0),arg1);
539                     return Py.None;
540                 } catch (PyObject.ConversionException e) {
541                     String JavaDoc msg;
542                     switch (e.index) {
543                     case 0:
544                         msg="expected an integer";
545                         break;
546                     default:
547                         msg="xxx";
548                     }
549                     throw Py.TypeError(msg);
550                 }
551             }
552
553             public PyObject inst_call(PyObject gself,PyObject arg0,PyObject arg1) {
554                 PyList self=(PyList)gself;
555                 try {
556                     self.list_insert(arg0.asInt(0),arg1);
557                     return Py.None;
558                 } catch (PyObject.ConversionException e) {
559                     String JavaDoc msg;
560                     switch (e.index) {
561                     case 0:
562                         msg="expected an integer";
563                         break;
564                     default:
565                         msg="xxx";
566                     }
567                     throw Py.TypeError(msg);
568                 }
569             }
570
571         }
572         dict.__setitem__("insert",new PyMethodDescr("insert",PyList.class,2,2,new exposed_insert(null,null)));
573         class exposed_pop extends PyBuiltinFunctionNarrow {
574
575             private PyList self;
576
577             public PyObject getSelf() {
578                 return self;
579             }
580
581             exposed_pop(PyList self,PyBuiltinFunction.Info info) {
582                 super(info);
583                 this.self=self;
584             }
585
586             public PyBuiltinFunction makeBound(PyObject self) {
587                 return new exposed_pop((PyList)self,info);
588             }
589
590             public PyObject __call__(PyObject arg0) {
591                 try {
592                     return self.list_pop(arg0.asInt(0));
593                 } catch (PyObject.ConversionException e) {
594                     String JavaDoc msg;
595                     switch (e.index) {
596                     case 0:
597                         msg="expected an integer";
598                         break;
599                     default:
600                         msg="xxx";
601                     }
602                     throw Py.TypeError(msg);
603                 }
604             }
605
606             public PyObject inst_call(PyObject gself,PyObject arg0) {
607                 PyList self=(PyList)gself;
608                 try {
609                     return self.list_pop(arg0.asInt(0));
610                 } catch (PyObject.ConversionException e) {
611                     String JavaDoc msg;
612                     switch (e.index) {
613                     case 0:
614                         msg="expected an integer";
615                         break;
616                     default:
617                         msg="xxx";
618                     }
619                     throw Py.TypeError(msg);
620                 }
621             }
622
623             public PyObject __call__() {
624                 return self.list_pop();
625             }
626
627             public PyObject inst_call(PyObject gself) {
628                 PyList self=(PyList)gself;
629                 return self.list_pop();
630             }
631
632         }
633         dict.__setitem__("pop",new PyMethodDescr("pop",PyList.class,0,1,new exposed_pop(null,null)));
634         class exposed_remove extends PyBuiltinFunctionNarrow {
635
636             private PyList self;
637
638             public PyObject getSelf() {
639                 return self;
640             }
641
642             exposed_remove(PyList self,PyBuiltinFunction.Info info) {
643                 super(info);
644                 this.self=self;
645             }
646
647             public PyBuiltinFunction makeBound(PyObject self) {
648                 return new exposed_remove((PyList)self,info);
649             }
650
651             public PyObject __call__(PyObject arg0) {
652                 self.list_remove(arg0);
653                 return Py.None;
654             }
655
656             public PyObject inst_call(PyObject gself,PyObject arg0) {
657                 PyList self=(PyList)gself;
658                 self.list_remove(arg0);
659                 return Py.None;
660             }
661
662         }
663         dict.__setitem__("remove",new PyMethodDescr("remove",PyList.class,1,1,new exposed_remove(null,null)));
664         class exposed_reverse extends PyBuiltinFunctionNarrow {
665
666             private PyList self;
667
668             public PyObject getSelf() {
669                 return self;
670             }
671
672             exposed_reverse(PyList self,PyBuiltinFunction.Info info) {
673                 super(info);
674                 this.self=self;
675             }
676
677             public PyBuiltinFunction makeBound(PyObject self) {
678                 return new exposed_reverse((PyList)self,info);
679             }
680
681             public PyObject __call__() {
682                 self.list_reverse();
683                 return Py.None;
684             }
685
686             public PyObject inst_call(PyObject gself) {
687                 PyList self=(PyList)gself;
688                 self.list_reverse();
689                 return Py.None;
690             }
691
692         }
693         dict.__setitem__("reverse",new PyMethodDescr("reverse",PyList.class,0,0,new exposed_reverse(null,null)));
694         class exposed_sort extends PyBuiltinFunctionNarrow {
695
696             private PyList self;
697
698             public PyObject getSelf() {
699                 return self;
700             }
701
702             exposed_sort(PyList self,PyBuiltinFunction.Info info) {
703                 super(info);
704                 this.self=self;
705             }
706
707             public PyBuiltinFunction makeBound(PyObject self) {
708                 return new exposed_sort((PyList)self,info);
709             }
710
711             public PyObject __call__(PyObject arg0) {
712                 self.list_sort(arg0);
713                 return Py.None;
714             }
715
716             public PyObject inst_call(PyObject gself,PyObject arg0) {
717                 PyList self=(PyList)gself;
718                 self.list_sort(arg0);
719                 return Py.None;
720             }
721
722             public PyObject __call__() {
723                 self.list_sort();
724                 return Py.None;
725             }
726
727             public PyObject inst_call(PyObject gself) {
728                 PyList self=(PyList)gself;
729                 self.list_sort();
730                 return Py.None;
731             }
732
733         }
734         dict.__setitem__("sort",new PyMethodDescr("sort",PyList.class,0,1,new exposed_sort(null,null)));
735         class exposed___len__ extends PyBuiltinFunctionNarrow {
736
737             private PyList self;
738
739             public PyObject getSelf() {
740                 return self;
741             }
742
743             exposed___len__(PyList self,PyBuiltinFunction.Info info) {
744                 super(info);
745                 this.self=self;
746             }
747
748             public PyBuiltinFunction makeBound(PyObject self) {
749                 return new exposed___len__((PyList)self,info);
750             }
751
752             public PyObject __call__() {
753                 return Py.newInteger(self.list___len__());
754             }
755
756             public PyObject inst_call(PyObject gself) {
757                 PyList self=(PyList)gself;
758                 return Py.newInteger(self.list___len__());
759             }
760
761         }
762         dict.__setitem__("__len__",new PyMethodDescr("__len__",PyList.class,0,0,new exposed___len__(null,null)));
763         class exposed___add__ extends PyBuiltinFunctionNarrow {
764
765             private PyList self;
766
767             public PyObject getSelf() {
768                 return self;
769             }
770
771             exposed___add__(PyList self,PyBuiltinFunction.Info info) {
772                 super(info);
773                 this.self=self;
774             }
775
776             public PyBuiltinFunction makeBound(PyObject self) {
777                 return new exposed___add__((PyList)self,info);
778             }
779
780             public PyObject __call__(PyObject arg0) {
781                 return self.list___add__(arg0);
782             }
783
784             public PyObject inst_call(PyObject gself,PyObject arg0) {
785                 PyList self=(PyList)gself;
786                 return self.list___add__(arg0);
787             }
788
789         }
790         dict.__setitem__("__add__",new PyMethodDescr("__add__",PyList.class,1,1,new exposed___add__(null,null)));
791         class exposed___radd__ extends PyBuiltinFunctionNarrow {
792
793             private PyList self;
794
795             public PyObject getSelf() {
796                 return self;
797             }
798
799             exposed___radd__(PyList self,PyBuiltinFunction.Info info) {
800                 super(info);
801                 this.self=self;
802             }
803
804             public PyBuiltinFunction makeBound(PyObject self) {
805                 return new exposed___radd__((PyList)self,info);
806             }
807
808             public PyObject __call__(PyObject arg0) {
809                 return self.list___radd__(arg0);
810             }
811
812             public PyObject inst_call(PyObject gself,PyObject arg0) {
813                 PyList self=(PyList)gself;
814                 return self.list___radd__(arg0);
815             }
816
817         }
818         dict.__setitem__("__radd__",new PyMethodDescr("__radd__",PyList.class,1,1,new exposed___radd__(null,null)));
819         class exposed___iadd__ extends PyBuiltinFunctionNarrow {
820
821             private PyList self;
822
823             public PyObject getSelf() {
824                 return self;
825             }
826
827             exposed___iadd__(PyList self,PyBuiltinFunction.Info info) {
828                 super(info);
829                 this.self=self;
830             }
831
832             public PyBuiltinFunction makeBound(PyObject self) {
833                 return new exposed___iadd__((PyList)self,info);
834             }
835
836             public PyObject __call__(PyObject arg0) {
837                 return self.list___iadd__(arg0);
838             }
839
840             public PyObject inst_call(PyObject gself,PyObject arg0) {
841                 PyList self=(PyList)gself;
842                 return self.list___iadd__(arg0);
843             }
844
845         }
846         dict.__setitem__("__iadd__",new PyMethodDescr("__iadd__",PyList.class,1,1,new exposed___iadd__(null,null)));
847         class exposed___imul__ extends PyBuiltinFunctionNarrow {
848
849             private PyList self;
850
851             public PyObject getSelf() {
852                 return self;
853             }
854
855             exposed___imul__(PyList self,PyBuiltinFunction.Info info) {
856                 super(info);
857                 this.self=self;
858             }
859
860             public PyBuiltinFunction makeBound(PyObject self) {
861                 return new exposed___imul__((PyList)self,info);
862             }
863
864             public PyObject __call__(PyObject arg0) {
865                 return self.list___imul__(arg0);
866             }
867
868             public PyObject inst_call(PyObject gself,PyObject arg0) {
869                 PyList self=(PyList)gself;
870                 return self.list___imul__(arg0);
871             }
872
873         }
874         dict.__setitem__("__imul__",new PyMethodDescr("__imul__",PyList.class,1,1,new exposed___imul__(null,null)));
875         class exposed___mul__ extends PyBuiltinFunctionNarrow {
876
877             private PyList self;
878
879             public PyObject getSelf() {
880                 return self;
881             }
882
883             exposed___mul__(PyList self,PyBuiltinFunction.Info info) {
884                 super(info);
885                 this.self=self;
886             }
887
888             public PyBuiltinFunction makeBound(PyObject self) {
889                 return new exposed___mul__((PyList)self,info);
890             }
891
892             public PyObject __call__(PyObject arg0) {
893                 return self.list___mul__(arg0);
894             }
895
896             public PyObject inst_call(PyObject gself,PyObject arg0) {
897                 PyList self=(PyList)gself;
898                 return self.list___mul__(arg0);
899             }
900
901         }
902         dict.__setitem__("__mul__",new PyMethodDescr("__mul__",PyList.class,1,1,new exposed___mul__(null,null)));
903         class exposed___rmul__ extends PyBuiltinFunctionNarrow {
904
905             private PyList self;
906
907             public PyObject getSelf() {
908                 return self;
909             }
910
911             exposed___rmul__(PyList self,PyBuiltinFunction.Info info) {
912                 super(info);
913                 this.self=self;
914             }
915
916             public PyBuiltinFunction makeBound(PyObject self) {
917                 return new exposed___rmul__((PyList)self,info);
918             }
919
920             public PyObject __call__(PyObject arg0) {
921                 return self.list___rmul__(arg0);
922             }
923
924             public PyObject inst_call(PyObject gself,PyObject arg0) {
925                 PyList self=(PyList)gself;
926                 return self.list___rmul__(arg0);
927             }
928
929         }
930         dict.__setitem__("__rmul__",new PyMethodDescr("__rmul__",PyList.class,1,1,new exposed___rmul__(null,null)));
931         class exposed___hash__ extends PyBuiltinFunctionNarrow {
932
933             private PyList self;
934
935             public PyObject getSelf() {
936                 return self;
937             }
938
939             exposed___hash__(PyList self,PyBuiltinFunction.Info info) {
940                 super(info);
941                 this.self=self;
942             }
943
944             public PyBuiltinFunction makeBound(PyObject self) {
945                 return new exposed___hash__((PyList)self,info);
946             }
947
948             public PyObject __call__() {
949                 return Py.newInteger(self.list_hashCode());
950             }
951
952             public PyObject inst_call(PyObject gself) {
953                 PyList self=(PyList)gself;
954                 return Py.newInteger(self.list_hashCode());
955             }
956
957         }
958         dict.__setitem__("__hash__",new PyMethodDescr("__hash__",PyList.class,0,0,new exposed___hash__(null,null)));
959         class exposed___repr__ extends PyBuiltinFunctionNarrow {
960
961             private PyList self;
962
963             public PyObject getSelf() {
964                 return self;
965             }
966
967             exposed___repr__(PyList self,PyBuiltinFunction.Info info) {
968                 super(info);
969                 this.self=self;
970             }
971
972             public PyBuiltinFunction makeBound(PyObject self) {
973                 return new exposed___repr__((PyList)self,info);
974             }
975
976             public PyObject __call__() {
977                 return new PyString(self.list_toString());
978             }
979
980             public PyObject inst_call(PyObject gself) {
981                 PyList self=(PyList)gself;
982                 return new PyString(self.list_toString());
983             }
984
985         }
986         dict.__setitem__("__repr__",new PyMethodDescr("__repr__",PyList.class,0,0,new exposed___repr__(null,null)));
987         class exposed___init__ extends PyBuiltinFunctionWide {
988
989             private PyList self;
990
991             public PyObject getSelf() {
992                 return self;
993             }
994
995             exposed___init__(PyList self,PyBuiltinFunction.Info info) {
996                 super(info);
997                 this.self=self;
998             }
999
1000            public PyBuiltinFunction makeBound(PyObject self) {
1001                return new exposed___init__((PyList)self,info);
1002            }
1003
1004            public PyObject inst_call(PyObject self,PyObject[]args) {
1005                return inst_call(self,args,Py.NoKeywords);
1006            }
1007
1008            public PyObject __call__(PyObject[]args) {
1009                return __call__(args,Py.NoKeywords);
1010            }
1011
1012            public PyObject __call__(PyObject[]args,String JavaDoc[]keywords) {
1013                self.list_init(args,keywords);
1014                return Py.None;
1015            }
1016
1017            public PyObject inst_call(PyObject gself,PyObject[]args,String JavaDoc[]keywords) {
1018                PyList self=(PyList)gself;
1019                self.list_init(args,keywords);
1020                return Py.None;
1021            }
1022
1023        }
1024        dict.__setitem__("__init__",new PyMethodDescr("__init__",PyList.class,-1,-1,new exposed___init__(null,null)));
1025        dict.__setitem__("__new__",new PyNewWrapper(PyList.class,"__new__",-1,-1) {
1026
1027        public PyObject new_impl(boolean init,PyType subtype,PyObject[]args,String JavaDoc[]keywords) {
1028            PyList newobj;
1029            if (for_type==subtype) {
1030                newobj=new PyList();
1031                if (init)
1032                    newobj.list_init(args,keywords);
1033                   } else {
1034                       newobj=new PyListDerived(subtype);
1035                   }
1036                   return newobj;
1037               }
1038
1039        });
1040    }
1041
1042    public PyList() {
1043        this(Py.EmptyObjects);
1044    }
1045
1046    public PyList(PyType type) {
1047        super(type);
1048    }
1049
1050    public PyList(Collection JavaDoc c) {
1051        super(c);
1052    }
1053
1054    // TODO: fix dependency so it can be removed.
1055
// Shouldn't be required (see PyList(Collection c), but test_re.py fails
1056
// without it. Probably used by reflection.
1057
public PyList(Vector JavaDoc v) {
1058        super(v);
1059    }
1060    
1061    public PyList(PyObject[] elements) {
1062        super(elements);
1063    }
1064
1065    public PyList(PyObject o) {
1066        this();
1067        PyObject iter = o.__iter__();
1068        for (PyObject item = null; (item = iter.__iternext__()) != null; ) {
1069            append(item);
1070        }
1071    }
1072
1073    final void list_init(PyObject[] args,String JavaDoc[] kwds) {
1074        int nargs = args.length - kwds.length;
1075        if (nargs > 1) {
1076            throw PyBuiltinFunction.DefaultInfo.unexpectedCall(nargs,false,exposed_name,0,1);
1077        }
1078        if (nargs == 0) {
1079            return;
1080        }
1081
1082        PyObject o = args[0];
1083        if (o instanceof PySequenceList) {
1084            PySequenceList p = (PySequenceList) o.__getslice__(Py.None, Py.None, Py.One);
1085            this.list = p.list;
1086        } else {
1087            PyObject iter = o.__iter__();
1088            for (PyObject item = null; (item = iter.__iternext__()) != null; ) {
1089                append(item);
1090            }
1091        }
1092    }
1093
1094    public String JavaDoc safeRepr() throws PyIgnoreMethodTag {
1095        return "'list' object";
1096    }
1097
1098    public int __len__() {
1099        return list___len__();
1100    }
1101
1102    final int list___len__() {
1103        return size();
1104    }
1105
1106    protected PyObject getslice(int start, int stop, int step) {
1107        if (step > 0 && stop < start)
1108            stop = start;
1109        int n = sliceLength(start, stop, step);
1110        PyObject[] newList = new PyObject[n];
1111        PyObject[] array = getArray();
1112
1113        if (step == 1) {
1114            System.arraycopy(array, start, newList, 0, stop-start);
1115            return new PyList(newList);
1116        }
1117        int j = 0;
1118        for (int i=start; j<n; i+=step) {
1119            newList[j] = array[i];
1120            j++;
1121        }
1122        return new PyList(newList);
1123    }
1124
1125    protected void del(int i) {
1126        remove(i);
1127    }
1128
1129    protected void delRange(int start, int stop, int step) {
1130        if (step == 1) {
1131            remove(start, stop);
1132        }
1133        else if (step > 1) {
1134            for(int i=start;i<stop;i+=step) {
1135                remove(i);
1136                i--;
1137                stop--;
1138            }
1139        }
1140        else if (step < 0) {
1141            for(int i=start;i>=0&&i>=stop;i+=step) {
1142                remove(i);
1143            }
1144        }
1145    }
1146
1147    protected void set(int i, PyObject value) {
1148        list.pyset(i, value);
1149    }
1150
1151// protected void setslice(int start, int stop, int step, PyObject value) {
1152
//
1153
// if (step != 1)
1154
// throw Py.ValueError("step size must be 1 for setting list slice");
1155
// if (stop < start)
1156
// stop = start;
1157
//
1158
// if (value instanceof PySequenceList) {
1159
//
1160
// if (value instanceof PyList) {
1161
// PyObject[] otherArray = null;
1162
// PyObject[] array = getArray();
1163
// PySequenceList seqList = (PySequenceList)value;
1164
// otherArray = seqList.getArray();
1165
// if (otherArray == array) {
1166
// otherArray = (PyObject[])otherArray.clone();
1167
// }
1168
// list.replaceSubArray(start, stop, otherArray, 0, seqList.size());
1169
// } else {
1170
// throw Py.TypeError("can only concatenate list (not \"" +
1171
// value.getType() + "\") to list");
1172
// }
1173
// } else {
1174
//
1175
// // also allow java.util.List
1176
// List other = (List)value.__tojava__(List.class);
1177
// if(other != Py.NoConversion) {
1178
// int n = other.size();
1179
// list.ensureCapacity(start + n);
1180
// for(int i=0; i<n; i++) {
1181
// list.add(i+start, other.get(i));
1182
// }
1183
// } else {
1184
// throw Py.TypeError(
1185
// "rhs of setslice must be a sequence or java.util.List");
1186
// }
1187
// }
1188
// }
1189
protected void setslice(int start, int stop, int step, PyObject value) {
1190
1191        if (stop < start)
1192            stop = start;
1193        
1194        if (step == 1) {
1195            if (value instanceof PySequence) {
1196            
1197                PySequence seq = (PySequence)value;
1198
1199                PyObject[] otherArray = null;
1200                PyObject[] array = getArray();
1201
1202                if (value instanceof PySequenceList) {
1203                    PySequenceList seqList = (PySequenceList)value;
1204                    otherArray = seqList.getArray();
1205                    if (otherArray == array) {
1206                        otherArray = (PyObject[])otherArray.clone();
1207                    }
1208                    list.replaceSubArray(start, stop, otherArray, 0, seqList.size());
1209                } else {
1210                    int n = seq.__len__();
1211                    list.ensureCapacity(start + n);
1212                    for(int i=0; i<n; i++) {
1213                        list.add(i+start, seq.pyget(i));
1214                    }
1215                }
1216            } else if (value instanceof List JavaDoc) {
1217                    List JavaDoc other = (List JavaDoc)value.__tojava__(List JavaDoc.class);
1218                    if(other != Py.NoConversion && other != null) {
1219                        int n = other.size();
1220                        list.ensureCapacity(start + n);
1221                        for(int i=0; i<n; i++) {
1222                            list.add(i+start, other.get(i));
1223                        }
1224                    }
1225            } else {
1226                throw Py.TypeError(
1227                                "rhs of setslice must be a sequence or java.util.List");
1228            }
1229        } else if (step > 1){
1230            if (value instanceof PySequence) {
1231                PySequence seq = (PySequence)value;
1232                int n = seq.__len__();
1233                for(int i=0,j=0; i<n; i++,j+=step) {
1234                    list.pyset(j+start, seq.pyget(i));
1235                }
1236            } else {
1237                throw Py.TypeError(
1238                             "setslice with java.util.List and step != 1 not supported yet.");
1239            }
1240                
1241        } else if (step < 0) {
1242            if (value instanceof PySequence) {
1243                PySequence seq = (PySequence)value;
1244                int n = seq.__len__();
1245                if (seq == this) {
1246                    PyList newseq = new PyList();
1247                    PyObject iter = seq.__iter__();
1248                    for (PyObject item = null; (item = iter.__iternext__()) != null; ) {
1249                        newseq.append(item);
1250                    }
1251                    seq = newseq;
1252                }
1253                for(int i=0,j=list.size() - 1; i<n; i++,j+=step) {
1254                    list.pyset(j, seq.pyget(i));
1255                }
1256            } else {
1257                throw Py.TypeError(
1258                            "setslice with java.util.List and step != 1 not supported yet.");
1259            }
1260         }
1261    }
1262    
1263    protected PyObject repeat(int count) {
1264        int l = size();
1265        PyObject[] newList = new PyObject[l*count];
1266        for (int i=0; i<count; i++) {
1267            System.arraycopy(getArray(), 0, newList, i*l, l);
1268        }
1269        return new PyList(newList);
1270    }
1271
1272    public PyObject __imul__(PyObject o) {
1273        return list___imul__(o);
1274    }
1275
1276    final PyObject list___imul__(PyObject o) {
1277        if (!(o instanceof PyInteger || o instanceof PyLong))
1278            throw Py.TypeError("can't multiply sequence to non-int");
1279        int l = size();
1280        int count = ((PyInteger)o.__int__()).getValue();
1281
1282        int newSize = l * count;
1283        list.ensureCapacity(newSize);
1284        list.setSize(newSize);
1285        //resize(l * count);
1286

1287        PyObject[] array = getArray();
1288        for (int i=1; i<count; i++) {
1289            System.arraycopy(array, 0, array, i*l, l);
1290        }
1291        return this;
1292    }
1293
1294    final PyObject list___mul__(PyObject o) {
1295        if (!(o instanceof PyInteger || o instanceof PyLong))
1296            throw Py.TypeError("can't multiply sequence to non-int");
1297        int count = ((PyInteger)o.__int__()).getValue();
1298        return repeat(count);
1299    }
1300
1301    final PyObject list___rmul__(PyObject o) {
1302        if (!(o instanceof PyInteger || o instanceof PyLong))
1303            throw Py.TypeError("can't multiply sequence to non-int");
1304        int count = ((PyInteger)o.__int__()).getValue();
1305        return repeat(count);
1306    }
1307
1308    public PyObject __add__(PyObject o) {
1309        return list___add__(o);
1310    }
1311
1312    final PyObject list___add__(PyObject o) {
1313        PyList sum = null;
1314        if (o instanceof PyList) {
1315            PyList other = (PyList)o;
1316            int thisLen = size();
1317            int otherLen = other.size();
1318            PyObject[] newList = new PyObject[thisLen+otherLen];
1319            System.arraycopy(getArray(), 0, newList, 0, thisLen);
1320            System.arraycopy(other.getArray(), 0, newList, thisLen, otherLen);
1321            sum = new PyList(newList);
1322        } else if ( !(o instanceof PySequenceList) ) {
1323            // also support adding java lists (but not PyTuple!)
1324
Object JavaDoc oList = o.__tojava__(List JavaDoc.class);
1325            if (oList != Py.NoConversion && oList != null) {
1326                List JavaDoc otherList = (List JavaDoc)oList;
1327                sum = new PyList();
1328                sum.list_extend(this);
1329                for (Iterator JavaDoc i = otherList.iterator(); i.hasNext(); ) {
1330                    sum.add(i.next());
1331                }
1332            }
1333        }
1334        return sum;
1335    }
1336 
1337    public PyObject __radd__(PyObject o) {
1338        return list___radd__(o);
1339    }
1340
1341    final PyObject list___radd__(PyObject o) {
1342        // Support adding java.util.List, but prevent adding PyTuple.
1343
// 'o' should never be a PyList since __add__ is defined.
1344
PyList sum = null;
1345        if (o instanceof PySequence) {
1346            return null;
1347        }
1348        Object JavaDoc oList = o.__tojava__(List JavaDoc.class);
1349        if(oList != Py.NoConversion && oList != null) {
1350            sum = new PyList();
1351            sum.addAll((List JavaDoc)oList);
1352            sum.extend(this);
1353        }
1354        return sum;
1355    }
1356    
1357    protected String JavaDoc unsupportedopMessage(String JavaDoc op, PyObject o2) {
1358        if (op.equals("+")) {
1359            return "can only concatenate list (not \"{2}\") to list";
1360        }
1361        return null;
1362    }
1363
1364    protected String JavaDoc runsupportedopMessage(String JavaDoc op, PyObject o2) {
1365        if (op.equals("+")) {
1366            return "can only concatenate list (not \"{1}\") to list";
1367        }
1368        return null;
1369    }
1370    
1371    public String JavaDoc toString() {
1372        return list_toString();
1373    }
1374
1375    final String JavaDoc list_toString() {
1376        ThreadState ts = Py.getThreadState();
1377        if (!ts.enterRepr(this)) {
1378            return "[...]";
1379        }
1380
1381        StringBuffer JavaDoc buf = new StringBuffer JavaDoc("[");
1382        int length = size();
1383        PyObject[] array = getArray();
1384        
1385        for (int i=0; i<length-1; i++) {
1386            buf.append((array[i]).__repr__().toString());
1387            buf.append(", ");
1388        }
1389        if (length > 0)
1390            buf.append((array[length-1]).__repr__().toString());
1391        buf.append("]");
1392
1393        ts.exitRepr(this);
1394        return buf.toString();
1395    }
1396
1397    /**
1398     * Add a single element to the end of list.
1399     *
1400     * @param o the element to add.
1401     */

1402    public void append(PyObject o) {
1403        list_append(o);
1404    }
1405
1406    final void list_append(PyObject o) {
1407        pyadd(o);
1408    }
1409
1410    /**
1411     * Return the number elements in the list that equals the argument.
1412     *
1413     * @param o the argument to test for. Testing is done with
1414     * the <code>==</code> operator.
1415     */

1416    public int count(PyObject o) {
1417        return list_count(o);
1418    }
1419
1420    final int list_count(PyObject o) {
1421        int count = 0;
1422        PyObject[] array = getArray();
1423        for (int i=0, n = size(); i<n; i++) {
1424            if (array[i].equals(o))
1425                count++;
1426        }
1427        return count;
1428    }
1429
1430    /**
1431     * return smallest index where an element in the list equals
1432     * the argument.
1433     *
1434     * @param o the argument to test for. Testing is done with
1435     * the <code>==</code> operator.
1436     */

1437    public int index(PyObject o) {
1438        return list_index(o, 0, size());
1439    }
1440    
1441    public int index(PyObject o, int start) {
1442        return list_index(o, start, size());
1443    }
1444    
1445    // CAU: not referenced anywheir, why is this here?
1446
public int index(PyObject o, int start, int stop) {
1447        return list_index(o, start, stop);
1448    }
1449
1450    final int list_index(PyObject o, int start, int stop) {
1451        return _index(o, "list.index(x): x not in list", start, stop);
1452    }
1453    
1454    final int list_index(PyObject o, int start) {
1455        return _index(o, "list.index(x): x not in list", start, size());
1456    }
1457    
1458    final int list_index(PyObject o) {
1459        return _index(o, "list.index(x): x not in list", 0, size());
1460    }
1461
1462    private int _index(PyObject o, String JavaDoc message, int start, int stop) {
1463        
1464        //Follow Python 2.3+ behavior
1465
int validStop = calculateIndex(stop);
1466        int validStart = calculateIndex(start);
1467        
1468        PyObject[] array = getArray();
1469        int i=validStart;
1470        for (; i<validStop; i++) {
1471            if (array[i].equals(o))
1472                break;
1473        }
1474        if (i == validStop)
1475            throw Py.ValueError(message);
1476        return i;
1477    }
1478
1479    //This is closely related to fixindex in PySequence, but less strict
1480
//fixindex returns -1 if index += length < 0 or if index >= length
1481
//where this function returns 0 in former case and length in the latter.
1482
//I think both are needed in different cases, but if this method turns
1483
//out to be needed in other sequence subclasses, it should be moved to
1484
//PySequence.
1485
private int calculateIndex(int index) {
1486        int length = size();
1487        if (index < 0) {
1488            index = index += length;
1489            if (index < 0) {
1490                index = 0;
1491            }
1492        } else if (index > length) {
1493            index = length;
1494        }
1495        return index;
1496    }
1497
1498
1499    /**
1500     * Insert the argument element into the list at the specified
1501     * index.
1502     * <br>
1503     * Same as <code>s[index:index] = [o] if index &gt;= 0</code>.
1504     *
1505     * @param index the position where the element will be inserted.
1506     * @param o the element to insert.
1507     */

1508    public void insert(int index, PyObject o) {
1509        list_insert(index, o);
1510    }
1511
1512    final void list_insert(int index, PyObject o) {
1513        if (index < 0) index = Math.max(0, size() + index);
1514        if (index > size()) index = size();
1515        list.pyadd(index, o);
1516    }
1517
1518    /**
1519     * Remove the first occurence of the argument from the list.
1520     * The elements arecompared with the <code>==</code> operator.
1521     * <br>
1522     * Same as <code>del s[s.index(x)]</code>
1523     *
1524     * @param o the element to search for and remove.
1525     */

1526    public void remove(PyObject o) {
1527        list_remove(o);
1528    }
1529
1530    final void list_remove(PyObject o) {
1531        del(_index(o, "list.remove(x): x not in list", 0, size()));
1532    }
1533
1534    /**
1535     * Reverses the items of s in place.
1536     * The reverse() methods modify the list in place for economy
1537     * of space when reversing a large list. It doesn't return the
1538     * reversed list to remind you of this side effect.
1539     */

1540    public void reverse() {
1541        list_reverse();
1542    }
1543
1544    final void list_reverse() {
1545        PyObject tmp;
1546        int n = size();
1547        PyObject[] array = getArray();
1548        int j = n-1;
1549        for (int i=0; i<n/2; i++, j--) {
1550            tmp = array[i];
1551            array[i] = array[j];
1552            array[j] = tmp;
1553        }
1554    }
1555
1556    /**
1557     * Removes and return the last element in the list.
1558     */

1559    public PyObject pop() {
1560        return list_pop();
1561    }
1562
1563    final PyObject list_pop() {
1564        return pop(-1);
1565    }
1566
1567    /**
1568     * Removes and return the <code>n</code> indexed element in the
1569     * list.
1570     *
1571     * @param n the index of the element to remove and return.
1572     */

1573    public PyObject pop(int n) {
1574        return list_pop(n);
1575    }
1576
1577    final PyObject list_pop(int n) {
1578        int length = size();
1579        if (length==0) {
1580            throw Py.IndexError("pop from empty list");
1581        }
1582        if (n < 0)
1583            n += length;
1584        if (n < 0 || n >= length)
1585            throw Py.IndexError("pop index out of range");
1586        PyObject v = pyget(n);
1587
1588        setslice(n, n+1, 1, Py.EmptyTuple);
1589        return v;
1590    }
1591
1592    /**
1593     * Append the elements in the argument sequence to the end of the list.
1594     * <br>
1595     * Same as <code>s[len(s):len(s)] = o</code>.
1596     *
1597     * @param o the sequence of items to append to the list.
1598     */

1599    public void extend(PyObject o) {
1600        list_extend(o);
1601    }
1602
1603    final void list_extend(PyObject o) {
1604        int length = size();
1605        setslice(length, length, 1, o);
1606    }
1607
1608    public PyObject __iadd__(PyObject o) {
1609        return list___iadd__(o);
1610    }
1611
1612    final PyObject list___iadd__(PyObject o) {
1613        extend(fastSequence(o, "argument to += must be a sequence"));
1614        return this;
1615    }
1616
1617    /**
1618     * Sort the items of the list in place. The compare argument is a
1619     * function of two arguments (list items) which should return
1620     * -1, 0 or 1 depending on whether the first argument is
1621     * considered smaller than, equal to, or larger than the second
1622     * argument. Note that this slows the sorting process down
1623     * considerably; e.g. to sort a list in reverse order it is much
1624     * faster to use calls to the methods sort() and reverse() than
1625     * to use the built-in function sort() with a comparison function
1626     * that reverses the ordering of the elements.
1627     *
1628     * @param compare the comparison function.
1629     */

1630    public synchronized void sort(PyObject compare) {
1631        list_sort(compare);
1632    }
1633
1634    final synchronized void list_sort(PyObject compare) {
1635        MergeState ms = new MergeState(getArray(), size(), compare);
1636        ms.sort();
1637    }
1638
1639    /**
1640     * Sort the items of the list in place. Items is compared with the
1641     * normal relative comparison operators.
1642     */

1643    public void sort() {
1644        list_sort();
1645    }
1646
1647    final void list_sort() {
1648        list_sort(null);
1649    }
1650
1651    public int hashCode() {
1652        return list_hashCode();
1653    }
1654
1655    final int list_hashCode() {
1656        throw Py.TypeError("unhashable type");
1657    }
1658}
1659
Popular Tags