Source Code Cross Referenced for PyList.java in  » Testing » Marathon » org » python » core » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Testing » Marathon » org.python.core 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        // Copyright (c) Corporation for National Research Initiatives
0002:
0003:        // Implementation of the standard Python list objects
0004:
0005:        package org.python.core;
0006:
0007:        import java.util.Collection;
0008:        import java.util.Iterator;
0009:        import java.util.List;
0010:        import java.util.Vector;
0011:
0012:        /**
0013:         * A builtin python list.
0014:         */
0015:
0016:        public class PyList extends PySequenceList {
0017:
0018:            public static void classDictInit(PyObject dict)
0019:                    throws PyIgnoreMethodTag {
0020:            }
0021:
0022:            //~ BEGIN GENERATED REGION -- DO NOT EDIT SEE gexpose.py
0023:            /* type info */
0024:
0025:            public static final String exposed_name = "list";
0026:
0027:            public static final Class exposed_base = PyObject.class;
0028:
0029:            public static void typeSetup(PyObject dict, PyType.Newstyle marker) {
0030:                class exposed___ne__ extends PyBuiltinMethodNarrow {
0031:
0032:                    exposed___ne__(PyObject self, PyBuiltinFunction.Info info) {
0033:                        super (self, info);
0034:                    }
0035:
0036:                    public PyBuiltinFunction bind(PyObject self) {
0037:                        return new exposed___ne__(self, info);
0038:                    }
0039:
0040:                    public PyObject __call__(PyObject arg0) {
0041:                        PyObject ret = ((PyList) self).seq___ne__(arg0);
0042:                        if (ret == null)
0043:                            return Py.NotImplemented;
0044:                        return ret;
0045:                    }
0046:
0047:                }
0048:                dict.__setitem__("__ne__", new PyMethodDescr("__ne__",
0049:                        PyList.class, 1, 1, new exposed___ne__(null, null)));
0050:                class exposed___eq__ extends PyBuiltinMethodNarrow {
0051:
0052:                    exposed___eq__(PyObject self, PyBuiltinFunction.Info info) {
0053:                        super (self, info);
0054:                    }
0055:
0056:                    public PyBuiltinFunction bind(PyObject self) {
0057:                        return new exposed___eq__(self, info);
0058:                    }
0059:
0060:                    public PyObject __call__(PyObject arg0) {
0061:                        PyObject ret = ((PyList) self).seq___eq__(arg0);
0062:                        if (ret == null)
0063:                            return Py.NotImplemented;
0064:                        return ret;
0065:                    }
0066:
0067:                }
0068:                dict.__setitem__("__eq__", new PyMethodDescr("__eq__",
0069:                        PyList.class, 1, 1, new exposed___eq__(null, null)));
0070:                class exposed___lt__ extends PyBuiltinMethodNarrow {
0071:
0072:                    exposed___lt__(PyObject self, PyBuiltinFunction.Info info) {
0073:                        super (self, info);
0074:                    }
0075:
0076:                    public PyBuiltinFunction bind(PyObject self) {
0077:                        return new exposed___lt__(self, info);
0078:                    }
0079:
0080:                    public PyObject __call__(PyObject arg0) {
0081:                        PyObject ret = ((PyList) self).seq___lt__(arg0);
0082:                        if (ret == null)
0083:                            return Py.NotImplemented;
0084:                        return ret;
0085:                    }
0086:
0087:                }
0088:                dict.__setitem__("__lt__", new PyMethodDescr("__lt__",
0089:                        PyList.class, 1, 1, new exposed___lt__(null, null)));
0090:                class exposed___le__ extends PyBuiltinMethodNarrow {
0091:
0092:                    exposed___le__(PyObject self, PyBuiltinFunction.Info info) {
0093:                        super (self, info);
0094:                    }
0095:
0096:                    public PyBuiltinFunction bind(PyObject self) {
0097:                        return new exposed___le__(self, info);
0098:                    }
0099:
0100:                    public PyObject __call__(PyObject arg0) {
0101:                        PyObject ret = ((PyList) self).seq___le__(arg0);
0102:                        if (ret == null)
0103:                            return Py.NotImplemented;
0104:                        return ret;
0105:                    }
0106:
0107:                }
0108:                dict.__setitem__("__le__", new PyMethodDescr("__le__",
0109:                        PyList.class, 1, 1, new exposed___le__(null, null)));
0110:                class exposed___gt__ extends PyBuiltinMethodNarrow {
0111:
0112:                    exposed___gt__(PyObject self, PyBuiltinFunction.Info info) {
0113:                        super (self, info);
0114:                    }
0115:
0116:                    public PyBuiltinFunction bind(PyObject self) {
0117:                        return new exposed___gt__(self, info);
0118:                    }
0119:
0120:                    public PyObject __call__(PyObject arg0) {
0121:                        PyObject ret = ((PyList) self).seq___gt__(arg0);
0122:                        if (ret == null)
0123:                            return Py.NotImplemented;
0124:                        return ret;
0125:                    }
0126:
0127:                }
0128:                dict.__setitem__("__gt__", new PyMethodDescr("__gt__",
0129:                        PyList.class, 1, 1, new exposed___gt__(null, null)));
0130:                class exposed___ge__ extends PyBuiltinMethodNarrow {
0131:
0132:                    exposed___ge__(PyObject self, PyBuiltinFunction.Info info) {
0133:                        super (self, info);
0134:                    }
0135:
0136:                    public PyBuiltinFunction bind(PyObject self) {
0137:                        return new exposed___ge__(self, info);
0138:                    }
0139:
0140:                    public PyObject __call__(PyObject arg0) {
0141:                        PyObject ret = ((PyList) self).seq___ge__(arg0);
0142:                        if (ret == null)
0143:                            return Py.NotImplemented;
0144:                        return ret;
0145:                    }
0146:
0147:                }
0148:                dict.__setitem__("__ge__", new PyMethodDescr("__ge__",
0149:                        PyList.class, 1, 1, new exposed___ge__(null, null)));
0150:                class exposed___getitem__ extends PyBuiltinMethodNarrow {
0151:
0152:                    exposed___getitem__(PyObject self,
0153:                            PyBuiltinFunction.Info info) {
0154:                        super (self, info);
0155:                    }
0156:
0157:                    public PyBuiltinFunction bind(PyObject self) {
0158:                        return new exposed___getitem__(self, info);
0159:                    }
0160:
0161:                    public PyObject __call__(PyObject arg0) {
0162:                        PyObject ret = ((PyList) self).seq___finditem__(arg0);
0163:                        if (ret == null) {
0164:                            throw Py.IndexError("index out of range: " + arg0);
0165:                        }
0166:                        return ret;
0167:                    }
0168:
0169:                }
0170:                dict.__setitem__("__getitem__", new PyMethodDescr(
0171:                        "__getitem__", PyList.class, 1, 1,
0172:                        new exposed___getitem__(null, null)));
0173:                class exposed___contains__ extends PyBuiltinMethodNarrow {
0174:
0175:                    exposed___contains__(PyObject self,
0176:                            PyBuiltinFunction.Info info) {
0177:                        super (self, info);
0178:                    }
0179:
0180:                    public PyBuiltinFunction bind(PyObject self) {
0181:                        return new exposed___contains__(self, info);
0182:                    }
0183:
0184:                    public PyObject __call__(PyObject arg0) {
0185:                        return Py.newBoolean(((PyList) self)
0186:                                .object___contains__(arg0));
0187:                    }
0188:
0189:                }
0190:                dict.__setitem__("__contains__", new PyMethodDescr(
0191:                        "__contains__", PyList.class, 1, 1,
0192:                        new exposed___contains__(null, null)));
0193:                class exposed___delitem__ extends PyBuiltinMethodNarrow {
0194:
0195:                    exposed___delitem__(PyObject self,
0196:                            PyBuiltinFunction.Info info) {
0197:                        super (self, info);
0198:                    }
0199:
0200:                    public PyBuiltinFunction bind(PyObject self) {
0201:                        return new exposed___delitem__(self, info);
0202:                    }
0203:
0204:                    public PyObject __call__(PyObject arg0) {
0205:                        ((PyList) self).seq___delitem__(arg0);
0206:                        return Py.None;
0207:                    }
0208:
0209:                }
0210:                dict.__setitem__("__delitem__", new PyMethodDescr(
0211:                        "__delitem__", PyList.class, 1, 1,
0212:                        new exposed___delitem__(null, null)));
0213:                class exposed___setitem__ extends PyBuiltinMethodNarrow {
0214:
0215:                    exposed___setitem__(PyObject self,
0216:                            PyBuiltinFunction.Info info) {
0217:                        super (self, info);
0218:                    }
0219:
0220:                    public PyBuiltinFunction bind(PyObject self) {
0221:                        return new exposed___setitem__(self, info);
0222:                    }
0223:
0224:                    public PyObject __call__(PyObject arg0, PyObject arg1) {
0225:                        ((PyList) self).seq___setitem__(arg0, arg1);
0226:                        return Py.None;
0227:                    }
0228:
0229:                }
0230:                dict.__setitem__("__setitem__", new PyMethodDescr(
0231:                        "__setitem__", PyList.class, 2, 2,
0232:                        new exposed___setitem__(null, null)));
0233:                class exposed___nonzero__ extends PyBuiltinMethodNarrow {
0234:
0235:                    exposed___nonzero__(PyObject self,
0236:                            PyBuiltinFunction.Info info) {
0237:                        super (self, info);
0238:                    }
0239:
0240:                    public PyBuiltinFunction bind(PyObject self) {
0241:                        return new exposed___nonzero__(self, info);
0242:                    }
0243:
0244:                    public PyObject __call__() {
0245:                        return Py.newBoolean(((PyList) self).seq___nonzero__());
0246:                    }
0247:
0248:                }
0249:                dict.__setitem__("__nonzero__", new PyMethodDescr(
0250:                        "__nonzero__", PyList.class, 0, 0,
0251:                        new exposed___nonzero__(null, null)));
0252:                class exposed___getslice__ extends PyBuiltinMethodNarrow {
0253:
0254:                    exposed___getslice__(PyObject self,
0255:                            PyBuiltinFunction.Info info) {
0256:                        super (self, info);
0257:                    }
0258:
0259:                    public PyBuiltinFunction bind(PyObject self) {
0260:                        return new exposed___getslice__(self, info);
0261:                    }
0262:
0263:                    public PyObject __call__(PyObject arg0, PyObject arg1,
0264:                            PyObject arg2) {
0265:                        return ((PyList) self).seq___getslice__(arg0, arg1,
0266:                                arg2);
0267:                    }
0268:
0269:                    public PyObject __call__(PyObject arg0, PyObject arg1) {
0270:                        return ((PyList) self).seq___getslice__(arg0, arg1);
0271:                    }
0272:
0273:                }
0274:                dict.__setitem__("__getslice__", new PyMethodDescr(
0275:                        "__getslice__", PyList.class, 2, 3,
0276:                        new exposed___getslice__(null, null)));
0277:                class exposed___delslice__ extends PyBuiltinMethodNarrow {
0278:
0279:                    exposed___delslice__(PyObject self,
0280:                            PyBuiltinFunction.Info info) {
0281:                        super (self, info);
0282:                    }
0283:
0284:                    public PyBuiltinFunction bind(PyObject self) {
0285:                        return new exposed___delslice__(self, info);
0286:                    }
0287:
0288:                    public PyObject __call__(PyObject arg0, PyObject arg1,
0289:                            PyObject arg2) {
0290:                        ((PyList) self).seq___delslice__(arg0, arg1, arg2);
0291:                        return Py.None;
0292:                    }
0293:
0294:                }
0295:                dict.__setitem__("__delslice__", new PyMethodDescr(
0296:                        "__delslice__", PyList.class, 3, 3,
0297:                        new exposed___delslice__(null, null)));
0298:                class exposed___setslice__ extends PyBuiltinMethodNarrow {
0299:
0300:                    exposed___setslice__(PyObject self,
0301:                            PyBuiltinFunction.Info info) {
0302:                        super (self, info);
0303:                    }
0304:
0305:                    public PyBuiltinFunction bind(PyObject self) {
0306:                        return new exposed___setslice__(self, info);
0307:                    }
0308:
0309:                    public PyObject __call__(PyObject arg0, PyObject arg1,
0310:                            PyObject arg2, PyObject arg3) {
0311:                        ((PyList) self)
0312:                                .seq___setslice__(arg0, arg1, arg2, arg3);
0313:                        return Py.None;
0314:                    }
0315:
0316:                    public PyObject __call__(PyObject arg0, PyObject arg1,
0317:                            PyObject arg2) {
0318:                        ((PyList) self).seq___setslice__(arg0, arg1, arg2);
0319:                        return Py.None;
0320:                    }
0321:
0322:                }
0323:                dict.__setitem__("__setslice__", new PyMethodDescr(
0324:                        "__setslice__", PyList.class, 3, 4,
0325:                        new exposed___setslice__(null, null)));
0326:                class exposed_append extends PyBuiltinMethodNarrow {
0327:
0328:                    exposed_append(PyObject self, PyBuiltinFunction.Info info) {
0329:                        super (self, info);
0330:                    }
0331:
0332:                    public PyBuiltinFunction bind(PyObject self) {
0333:                        return new exposed_append(self, info);
0334:                    }
0335:
0336:                    public PyObject __call__(PyObject arg0) {
0337:                        ((PyList) self).list_append(arg0);
0338:                        return Py.None;
0339:                    }
0340:
0341:                }
0342:                dict.__setitem__("append", new PyMethodDescr("append",
0343:                        PyList.class, 1, 1, new exposed_append(null, null)));
0344:                class exposed_count extends PyBuiltinMethodNarrow {
0345:
0346:                    exposed_count(PyObject self, PyBuiltinFunction.Info info) {
0347:                        super (self, info);
0348:                    }
0349:
0350:                    public PyBuiltinFunction bind(PyObject self) {
0351:                        return new exposed_count(self, info);
0352:                    }
0353:
0354:                    public PyObject __call__(PyObject arg0) {
0355:                        return Py.newInteger(((PyList) self).list_count(arg0));
0356:                    }
0357:
0358:                }
0359:                dict.__setitem__("count", new PyMethodDescr("count",
0360:                        PyList.class, 1, 1, new exposed_count(null, null)));
0361:                class exposed_extend extends PyBuiltinMethodNarrow {
0362:
0363:                    exposed_extend(PyObject self, PyBuiltinFunction.Info info) {
0364:                        super (self, info);
0365:                    }
0366:
0367:                    public PyBuiltinFunction bind(PyObject self) {
0368:                        return new exposed_extend(self, info);
0369:                    }
0370:
0371:                    public PyObject __call__(PyObject arg0) {
0372:                        ((PyList) self).list_extend(arg0);
0373:                        return Py.None;
0374:                    }
0375:
0376:                }
0377:                dict.__setitem__("extend", new PyMethodDescr("extend",
0378:                        PyList.class, 1, 1, new exposed_extend(null, null)));
0379:                class exposed_index extends PyBuiltinMethodNarrow {
0380:
0381:                    exposed_index(PyObject self, PyBuiltinFunction.Info info) {
0382:                        super (self, info);
0383:                    }
0384:
0385:                    public PyBuiltinFunction bind(PyObject self) {
0386:                        return new exposed_index(self, info);
0387:                    }
0388:
0389:                    public PyObject __call__(PyObject arg0, PyObject arg1,
0390:                            PyObject arg2) {
0391:                        try {
0392:                            return Py.newInteger(((PyList) self).list_index(
0393:                                    arg0, arg1.asInt(1), arg2.asInt(2)));
0394:                        } catch (PyObject.ConversionException e) {
0395:                            String msg;
0396:                            switch (e.index) {
0397:                            case 1:
0398:                            case 2:
0399:                                msg = "expected an integer";
0400:                                break;
0401:                            default:
0402:                                msg = "xxx";
0403:                            }
0404:                            throw Py.TypeError(msg);
0405:                        }
0406:                    }
0407:
0408:                    public PyObject __call__(PyObject arg0, PyObject arg1) {
0409:                        try {
0410:                            return Py.newInteger(((PyList) self).list_index(
0411:                                    arg0, arg1.asInt(1)));
0412:                        } catch (PyObject.ConversionException e) {
0413:                            String msg;
0414:                            switch (e.index) {
0415:                            case 1:
0416:                                msg = "expected an integer";
0417:                                break;
0418:                            default:
0419:                                msg = "xxx";
0420:                            }
0421:                            throw Py.TypeError(msg);
0422:                        }
0423:                    }
0424:
0425:                    public PyObject __call__(PyObject arg0) {
0426:                        return Py.newInteger(((PyList) self).list_index(arg0));
0427:                    }
0428:
0429:                }
0430:                dict.__setitem__("index", new PyMethodDescr("index",
0431:                        PyList.class, 1, 3, new exposed_index(null, null)));
0432:                class exposed_insert extends PyBuiltinMethodNarrow {
0433:
0434:                    exposed_insert(PyObject self, PyBuiltinFunction.Info info) {
0435:                        super (self, info);
0436:                    }
0437:
0438:                    public PyBuiltinFunction bind(PyObject self) {
0439:                        return new exposed_insert(self, info);
0440:                    }
0441:
0442:                    public PyObject __call__(PyObject arg0, PyObject arg1) {
0443:                        try {
0444:                            ((PyList) self).list_insert(arg0.asInt(0), arg1);
0445:                            return Py.None;
0446:                        } catch (PyObject.ConversionException e) {
0447:                            String msg;
0448:                            switch (e.index) {
0449:                            case 0:
0450:                                msg = "expected an integer";
0451:                                break;
0452:                            default:
0453:                                msg = "xxx";
0454:                            }
0455:                            throw Py.TypeError(msg);
0456:                        }
0457:                    }
0458:
0459:                }
0460:                dict.__setitem__("insert", new PyMethodDescr("insert",
0461:                        PyList.class, 2, 2, new exposed_insert(null, null)));
0462:                class exposed_pop extends PyBuiltinMethodNarrow {
0463:
0464:                    exposed_pop(PyObject self, PyBuiltinFunction.Info info) {
0465:                        super (self, info);
0466:                    }
0467:
0468:                    public PyBuiltinFunction bind(PyObject self) {
0469:                        return new exposed_pop(self, info);
0470:                    }
0471:
0472:                    public PyObject __call__(PyObject arg0) {
0473:                        try {
0474:                            return ((PyList) self).list_pop(arg0.asInt(0));
0475:                        } catch (PyObject.ConversionException e) {
0476:                            String msg;
0477:                            switch (e.index) {
0478:                            case 0:
0479:                                msg = "expected an integer";
0480:                                break;
0481:                            default:
0482:                                msg = "xxx";
0483:                            }
0484:                            throw Py.TypeError(msg);
0485:                        }
0486:                    }
0487:
0488:                    public PyObject __call__() {
0489:                        return ((PyList) self).list_pop();
0490:                    }
0491:
0492:                }
0493:                dict.__setitem__("pop", new PyMethodDescr("pop", PyList.class,
0494:                        0, 1, new exposed_pop(null, null)));
0495:                class exposed_remove extends PyBuiltinMethodNarrow {
0496:
0497:                    exposed_remove(PyObject self, PyBuiltinFunction.Info info) {
0498:                        super (self, info);
0499:                    }
0500:
0501:                    public PyBuiltinFunction bind(PyObject self) {
0502:                        return new exposed_remove(self, info);
0503:                    }
0504:
0505:                    public PyObject __call__(PyObject arg0) {
0506:                        ((PyList) self).list_remove(arg0);
0507:                        return Py.None;
0508:                    }
0509:
0510:                }
0511:                dict.__setitem__("remove", new PyMethodDescr("remove",
0512:                        PyList.class, 1, 1, new exposed_remove(null, null)));
0513:                class exposed_reverse extends PyBuiltinMethodNarrow {
0514:
0515:                    exposed_reverse(PyObject self, PyBuiltinFunction.Info info) {
0516:                        super (self, info);
0517:                    }
0518:
0519:                    public PyBuiltinFunction bind(PyObject self) {
0520:                        return new exposed_reverse(self, info);
0521:                    }
0522:
0523:                    public PyObject __call__() {
0524:                        ((PyList) self).list_reverse();
0525:                        return Py.None;
0526:                    }
0527:
0528:                }
0529:                dict.__setitem__("reverse", new PyMethodDescr("reverse",
0530:                        PyList.class, 0, 0, new exposed_reverse(null, null)));
0531:                class exposed_sort extends PyBuiltinMethodNarrow {
0532:
0533:                    exposed_sort(PyObject self, PyBuiltinFunction.Info info) {
0534:                        super (self, info);
0535:                    }
0536:
0537:                    public PyBuiltinFunction bind(PyObject self) {
0538:                        return new exposed_sort(self, info);
0539:                    }
0540:
0541:                    public PyObject __call__(PyObject arg0) {
0542:                        ((PyList) self).list_sort(arg0);
0543:                        return Py.None;
0544:                    }
0545:
0546:                    public PyObject __call__() {
0547:                        ((PyList) self).list_sort();
0548:                        return Py.None;
0549:                    }
0550:
0551:                }
0552:                dict.__setitem__("sort", new PyMethodDescr("sort",
0553:                        PyList.class, 0, 1, new exposed_sort(null, null)));
0554:                class exposed___len__ extends PyBuiltinMethodNarrow {
0555:
0556:                    exposed___len__(PyObject self, PyBuiltinFunction.Info info) {
0557:                        super (self, info);
0558:                    }
0559:
0560:                    public PyBuiltinFunction bind(PyObject self) {
0561:                        return new exposed___len__(self, info);
0562:                    }
0563:
0564:                    public PyObject __call__() {
0565:                        return Py.newInteger(((PyList) self).list___len__());
0566:                    }
0567:
0568:                }
0569:                dict.__setitem__("__len__", new PyMethodDescr("__len__",
0570:                        PyList.class, 0, 0, new exposed___len__(null, null)));
0571:                class exposed___add__ extends PyBuiltinMethodNarrow {
0572:
0573:                    exposed___add__(PyObject self, PyBuiltinFunction.Info info) {
0574:                        super (self, info);
0575:                    }
0576:
0577:                    public PyBuiltinFunction bind(PyObject self) {
0578:                        return new exposed___add__(self, info);
0579:                    }
0580:
0581:                    public PyObject __call__(PyObject arg0) {
0582:                        return ((PyList) self).list___add__(arg0);
0583:                    }
0584:
0585:                }
0586:                dict.__setitem__("__add__", new PyMethodDescr("__add__",
0587:                        PyList.class, 1, 1, new exposed___add__(null, null)));
0588:                class exposed___radd__ extends PyBuiltinMethodNarrow {
0589:
0590:                    exposed___radd__(PyObject self, PyBuiltinFunction.Info info) {
0591:                        super (self, info);
0592:                    }
0593:
0594:                    public PyBuiltinFunction bind(PyObject self) {
0595:                        return new exposed___radd__(self, info);
0596:                    }
0597:
0598:                    public PyObject __call__(PyObject arg0) {
0599:                        return ((PyList) self).list___radd__(arg0);
0600:                    }
0601:
0602:                }
0603:                dict.__setitem__("__radd__", new PyMethodDescr("__radd__",
0604:                        PyList.class, 1, 1, new exposed___radd__(null, null)));
0605:                class exposed___iadd__ extends PyBuiltinMethodNarrow {
0606:
0607:                    exposed___iadd__(PyObject self, PyBuiltinFunction.Info info) {
0608:                        super (self, info);
0609:                    }
0610:
0611:                    public PyBuiltinFunction bind(PyObject self) {
0612:                        return new exposed___iadd__(self, info);
0613:                    }
0614:
0615:                    public PyObject __call__(PyObject arg0) {
0616:                        return ((PyList) self).list___iadd__(arg0);
0617:                    }
0618:
0619:                }
0620:                dict.__setitem__("__iadd__", new PyMethodDescr("__iadd__",
0621:                        PyList.class, 1, 1, new exposed___iadd__(null, null)));
0622:                class exposed___imul__ extends PyBuiltinMethodNarrow {
0623:
0624:                    exposed___imul__(PyObject self, PyBuiltinFunction.Info info) {
0625:                        super (self, info);
0626:                    }
0627:
0628:                    public PyBuiltinFunction bind(PyObject self) {
0629:                        return new exposed___imul__(self, info);
0630:                    }
0631:
0632:                    public PyObject __call__(PyObject arg0) {
0633:                        return ((PyList) self).list___imul__(arg0);
0634:                    }
0635:
0636:                }
0637:                dict.__setitem__("__imul__", new PyMethodDescr("__imul__",
0638:                        PyList.class, 1, 1, new exposed___imul__(null, null)));
0639:                class exposed___reduce__ extends PyBuiltinMethodNarrow {
0640:
0641:                    exposed___reduce__(PyObject self,
0642:                            PyBuiltinFunction.Info info) {
0643:                        super (self, info);
0644:                    }
0645:
0646:                    public PyBuiltinFunction bind(PyObject self) {
0647:                        return new exposed___reduce__(self, info);
0648:                    }
0649:
0650:                    public PyObject __call__() {
0651:                        return ((PyList) self).list___reduce__();
0652:                    }
0653:
0654:                }
0655:                dict
0656:                        .__setitem__("__reduce__", new PyMethodDescr(
0657:                                "__reduce__", PyList.class, 0, 0,
0658:                                new exposed___reduce__(null, null)));
0659:                class exposed___mul__ extends PyBuiltinMethodNarrow {
0660:
0661:                    exposed___mul__(PyObject self, PyBuiltinFunction.Info info) {
0662:                        super (self, info);
0663:                    }
0664:
0665:                    public PyBuiltinFunction bind(PyObject self) {
0666:                        return new exposed___mul__(self, info);
0667:                    }
0668:
0669:                    public PyObject __call__(PyObject arg0) {
0670:                        return ((PyList) self).list___mul__(arg0);
0671:                    }
0672:
0673:                }
0674:                dict.__setitem__("__mul__", new PyMethodDescr("__mul__",
0675:                        PyList.class, 1, 1, new exposed___mul__(null, null)));
0676:                class exposed___rmul__ extends PyBuiltinMethodNarrow {
0677:
0678:                    exposed___rmul__(PyObject self, PyBuiltinFunction.Info info) {
0679:                        super (self, info);
0680:                    }
0681:
0682:                    public PyBuiltinFunction bind(PyObject self) {
0683:                        return new exposed___rmul__(self, info);
0684:                    }
0685:
0686:                    public PyObject __call__(PyObject arg0) {
0687:                        return ((PyList) self).list___rmul__(arg0);
0688:                    }
0689:
0690:                }
0691:                dict.__setitem__("__rmul__", new PyMethodDescr("__rmul__",
0692:                        PyList.class, 1, 1, new exposed___rmul__(null, null)));
0693:                class exposed___hash__ extends PyBuiltinMethodNarrow {
0694:
0695:                    exposed___hash__(PyObject self, PyBuiltinFunction.Info info) {
0696:                        super (self, info);
0697:                    }
0698:
0699:                    public PyBuiltinFunction bind(PyObject self) {
0700:                        return new exposed___hash__(self, info);
0701:                    }
0702:
0703:                    public PyObject __call__() {
0704:                        return Py.newInteger(((PyList) self).list_hashCode());
0705:                    }
0706:
0707:                }
0708:                dict.__setitem__("__hash__", new PyMethodDescr("__hash__",
0709:                        PyList.class, 0, 0, new exposed___hash__(null, null)));
0710:                class exposed___repr__ extends PyBuiltinMethodNarrow {
0711:
0712:                    exposed___repr__(PyObject self, PyBuiltinFunction.Info info) {
0713:                        super (self, info);
0714:                    }
0715:
0716:                    public PyBuiltinFunction bind(PyObject self) {
0717:                        return new exposed___repr__(self, info);
0718:                    }
0719:
0720:                    public PyObject __call__() {
0721:                        return new PyString(((PyList) self).list_toString());
0722:                    }
0723:
0724:                }
0725:                dict.__setitem__("__repr__", new PyMethodDescr("__repr__",
0726:                        PyList.class, 0, 0, new exposed___repr__(null, null)));
0727:                class exposed___init__ extends PyBuiltinMethod {
0728:
0729:                    exposed___init__(PyObject self, PyBuiltinFunction.Info info) {
0730:                        super (self, info);
0731:                    }
0732:
0733:                    public PyBuiltinFunction bind(PyObject self) {
0734:                        return new exposed___init__(self, info);
0735:                    }
0736:
0737:                    public PyObject __call__(PyObject[] args) {
0738:                        return __call__(args, Py.NoKeywords);
0739:                    }
0740:
0741:                    public PyObject __call__(PyObject[] args, String[] keywords) {
0742:                        ((PyList) self).list_init(args, keywords);
0743:                        return Py.None;
0744:                    }
0745:
0746:                }
0747:                dict
0748:                        .__setitem__("__init__", new PyMethodDescr("__init__",
0749:                                PyList.class, -1, -1, new exposed___init__(
0750:                                        null, null)));
0751:                dict.__setitem__("__new__", new PyNewWrapper(PyList.class,
0752:                        "__new__", -1, -1) {
0753:
0754:                    public PyObject new_impl(boolean init, PyType subtype,
0755:                            PyObject[] args, String[] keywords) {
0756:                        PyList newobj;
0757:                        if (for_type == subtype) {
0758:                            newobj = new PyList();
0759:                            if (init)
0760:                                newobj.list_init(args, keywords);
0761:                        } else {
0762:                            newobj = new PyListDerived(subtype);
0763:                        }
0764:                        return newobj;
0765:                    }
0766:
0767:                });
0768:            }
0769:
0770:            //~ END GENERATED REGION -- DO NOT EDIT SEE gexpose.py
0771:
0772:            private static final PyType LISTTYPE = PyType
0773:                    .fromClass(PyList.class);
0774:
0775:            public PyList() {
0776:                this (LISTTYPE, Py.EmptyObjects);
0777:            }
0778:
0779:            public PyList(PyType type) {
0780:                super (type);
0781:            }
0782:
0783:            public PyList(PyType type, PyObject[] elements) {
0784:                super (type, elements);
0785:            }
0786:
0787:            public PyList(PyType type, Collection c) {
0788:                super (type, c);
0789:            }
0790:
0791:            // TODO: fix dependency so it can be removed.
0792:            // Shouldn't be required (see PyList(Collection c), but test_re.py fails 
0793:            // without it.  Probably used by reflection.
0794:            public PyList(Vector v) {
0795:                super (LISTTYPE, v);
0796:            }
0797:
0798:            public PyList(PyObject[] elements) {
0799:                this (LISTTYPE, elements);
0800:            }
0801:
0802:            public PyList(PyObject o) {
0803:                this (LISTTYPE);
0804:                PyObject iter = o.__iter__();
0805:                for (PyObject item = null; (item = iter.__iternext__()) != null;) {
0806:                    append(item);
0807:                }
0808:            }
0809:
0810:            final void list_init(PyObject[] args, String[] kwds) {
0811:                ArgParser ap = new ArgParser("list", args, kwds,
0812:                        new String[] { "sequence" }, 0);
0813:                PyObject seq = ap.getPyObject(0, null);
0814:                if (seq == null) {
0815:                    return;
0816:                }
0817:
0818:                if (seq instanceof  PySequenceList) {
0819:                    PySequenceList p = (PySequenceList) seq.__getslice__(
0820:                            Py.None, Py.None, Py.One);
0821:                    this .list = p.list;
0822:                } else {
0823:                    PyObject iter = seq.__iter__();
0824:                    for (PyObject item = null; (item = iter.__iternext__()) != null;) {
0825:                        append(item);
0826:                    }
0827:                }
0828:            }
0829:
0830:            public String safeRepr() throws PyIgnoreMethodTag {
0831:                return "'list' object";
0832:            }
0833:
0834:            public int __len__() {
0835:                return list___len__();
0836:            }
0837:
0838:            final int list___len__() {
0839:                return size();
0840:            }
0841:
0842:            protected PyObject getslice(int start, int stop, int step) {
0843:                if (step > 0 && stop < start)
0844:                    stop = start;
0845:                int n = sliceLength(start, stop, step);
0846:                PyObject[] newList = new PyObject[n];
0847:                PyObject[] array = getArray();
0848:
0849:                if (step == 1) {
0850:                    System.arraycopy(array, start, newList, 0, stop - start);
0851:                    return new PyList(newList);
0852:                }
0853:                int j = 0;
0854:                for (int i = start; j < n; i += step) {
0855:                    newList[j] = array[i];
0856:                    j++;
0857:                }
0858:                return new PyList(newList);
0859:            }
0860:
0861:            protected void del(int i) {
0862:                remove(i);
0863:            }
0864:
0865:            protected void delRange(int start, int stop, int step) {
0866:                if (step == 1) {
0867:                    remove(start, stop);
0868:                } else if (step > 1) {
0869:                    for (int i = start; i < stop; i += step) {
0870:                        remove(i);
0871:                        i--;
0872:                        stop--;
0873:                    }
0874:                } else if (step < 0) {
0875:                    for (int i = start; i >= 0 && i >= stop; i += step) {
0876:                        remove(i);
0877:                    }
0878:                }
0879:            }
0880:
0881:            protected void set(int i, PyObject value) {
0882:                list.pyset(i, value);
0883:            }
0884:
0885:            //    protected void setslice(int start, int stop, int step, PyObject value) {
0886:            //
0887:            //        if (step != 1)
0888:            //            throw Py.ValueError("step size must be 1 for setting list slice");
0889:            //        if (stop < start)
0890:            //            stop = start;
0891:            //        
0892:            //        if (value instanceof PySequenceList) {
0893:            //            
0894:            //            if (value instanceof PyList) {
0895:            //                PyObject[] otherArray = null;
0896:            //                PyObject[] array = getArray(); 
0897:            //                   PySequenceList seqList = (PySequenceList)value;
0898:            //                   otherArray = seqList.getArray();
0899:            //                   if (otherArray == array) {
0900:            //                       otherArray = (PyObject[])otherArray.clone();
0901:            //                   }
0902:            //                   list.replaceSubArray(start, stop, otherArray, 0, seqList.size());
0903:            //            } else {
0904:            //                   throw Py.TypeError("can only concatenate list (not \"" +
0905:            //                           value.getType() + "\") to list");
0906:            //            }
0907:            //        } else { 
0908:            //            
0909:            //            // also allow java.util.List
0910:            //            List other = (List)value.__tojava__(List.class);
0911:            //            if(other != Py.NoConversion) {
0912:            //                   int n = other.size();
0913:            //                   list.ensureCapacity(start + n);
0914:            //                   for(int i=0; i<n; i++) {
0915:            //                       list.add(i+start, other.get(i));
0916:            //                   }
0917:            //            } else {        
0918:            //                throw Py.TypeError(
0919:            //                              "rhs of setslice must be a sequence or java.util.List");
0920:            //            }
0921:            //        }
0922:            //    }    
0923:            protected void setslice(int start, int stop, int step,
0924:                    PyObject value) {
0925:
0926:                if (stop < start)
0927:                    stop = start;
0928:
0929:                if (step == 1) {
0930:                    if (value instanceof  PySequence) {
0931:
0932:                        PySequence seq = (PySequence) value;
0933:
0934:                        PyObject[] otherArray = null;
0935:                        PyObject[] array = getArray();
0936:
0937:                        if (value instanceof  PySequenceList) {
0938:                            PySequenceList seqList = (PySequenceList) value;
0939:                            otherArray = seqList.getArray();
0940:                            if (otherArray == array) {
0941:                                otherArray = (PyObject[]) otherArray.clone();
0942:                            }
0943:                            list.replaceSubArray(start, stop, otherArray, 0,
0944:                                    seqList.size());
0945:                        } else {
0946:                            int n = seq.__len__();
0947:                            list.ensureCapacity(start + n);
0948:                            for (int i = 0; i < n; i++) {
0949:                                list.add(i + start, seq.pyget(i));
0950:                            }
0951:                        }
0952:                    } else if (value instanceof  List) {
0953:                        List other = (List) value.__tojava__(List.class);
0954:                        if (other != Py.NoConversion && other != null) {
0955:                            int n = other.size();
0956:                            list.ensureCapacity(start + n);
0957:                            for (int i = 0; i < n; i++) {
0958:                                list.add(i + start, other.get(i));
0959:                            }
0960:                        }
0961:                    } else {
0962:                        throw Py
0963:                                .TypeError("rhs of setslice must be a sequence or java.util.List");
0964:                    }
0965:                } else if (step > 1) {
0966:                    if (value instanceof  PySequence) {
0967:                        PySequence seq = (PySequence) value;
0968:                        int n = seq.__len__();
0969:                        for (int i = 0, j = 0; i < n; i++, j += step) {
0970:                            list.pyset(j + start, seq.pyget(i));
0971:                        }
0972:                    } else {
0973:                        throw Py
0974:                                .TypeError("setslice with java.util.List and step != 1 not supported yet.");
0975:                    }
0976:
0977:                } else if (step < 0) {
0978:                    if (value instanceof  PySequence) {
0979:                        PySequence seq = (PySequence) value;
0980:                        int n = seq.__len__();
0981:                        if (seq == this ) {
0982:                            PyList newseq = new PyList();
0983:                            PyObject iter = seq.__iter__();
0984:                            for (PyObject item = null; (item = iter
0985:                                    .__iternext__()) != null;) {
0986:                                newseq.append(item);
0987:                            }
0988:                            seq = newseq;
0989:                        }
0990:                        for (int i = 0, j = list.size() - 1; i < n; i++, j += step) {
0991:                            list.pyset(j, seq.pyget(i));
0992:                        }
0993:                    } else {
0994:                        throw Py
0995:                                .TypeError("setslice with java.util.List and step != 1 not supported yet.");
0996:                    }
0997:                }
0998:            }
0999:
1000:            protected PyObject repeat(int count) {
1001:                int l = size();
1002:                PyObject[] newList = new PyObject[l * count];
1003:                for (int i = 0; i < count; i++) {
1004:                    System.arraycopy(getArray(), 0, newList, i * l, l);
1005:                }
1006:                return new PyList(newList);
1007:            }
1008:
1009:            public PyObject __imul__(PyObject o) {
1010:                return list___imul__(o);
1011:            }
1012:
1013:            final PyObject list___imul__(PyObject o) {
1014:                if (!(o instanceof  PyInteger || o instanceof  PyLong))
1015:                    throw Py.TypeError("can't multiply sequence to non-int");
1016:                int l = size();
1017:                int count = ((PyInteger) o.__int__()).getValue();
1018:
1019:                int newSize = l * count;
1020:                list.ensureCapacity(newSize);
1021:                list.setSize(newSize);
1022:                //resize(l * count);
1023:
1024:                PyObject[] array = getArray();
1025:                for (int i = 1; i < count; i++) {
1026:                    System.arraycopy(array, 0, array, i * l, l);
1027:                }
1028:                return this ;
1029:            }
1030:
1031:            final PyObject list___mul__(PyObject o) {
1032:                if (!(o instanceof  PyInteger || o instanceof  PyLong))
1033:                    throw Py.TypeError("can't multiply sequence to non-int");
1034:                int count = ((PyInteger) o.__int__()).getValue();
1035:                return repeat(count);
1036:            }
1037:
1038:            final PyObject list___rmul__(PyObject o) {
1039:                if (!(o instanceof  PyInteger || o instanceof  PyLong))
1040:                    throw Py.TypeError("can't multiply sequence to non-int");
1041:                int count = ((PyInteger) o.__int__()).getValue();
1042:                return repeat(count);
1043:            }
1044:
1045:            public PyObject __add__(PyObject o) {
1046:                return list___add__(o);
1047:            }
1048:
1049:            final PyObject list___add__(PyObject o) {
1050:                PyList sum = null;
1051:                if (o instanceof  PyList) {
1052:                    PyList other = (PyList) o;
1053:                    int this Len = size();
1054:                    int otherLen = other.size();
1055:                    PyObject[] newList = new PyObject[this Len + otherLen];
1056:                    System.arraycopy(getArray(), 0, newList, 0, this Len);
1057:                    System.arraycopy(other.getArray(), 0, newList, this Len,
1058:                            otherLen);
1059:                    sum = new PyList(newList);
1060:                } else if (!(o instanceof  PySequenceList)) {
1061:                    // also support adding java lists (but not PyTuple!)
1062:                    Object oList = o.__tojava__(List.class);
1063:                    if (oList != Py.NoConversion && oList != null) {
1064:                        List otherList = (List) oList;
1065:                        sum = new PyList();
1066:                        sum.list_extend(this );
1067:                        for (Iterator i = otherList.iterator(); i.hasNext();) {
1068:                            sum.add(i.next());
1069:                        }
1070:                    }
1071:                }
1072:                return sum;
1073:            }
1074:
1075:            public PyObject __radd__(PyObject o) {
1076:                return list___radd__(o);
1077:            }
1078:
1079:            final PyObject list___radd__(PyObject o) {
1080:                // Support adding java.util.List, but prevent adding PyTuple.
1081:                // 'o' should never be a PyList since __add__ is defined.
1082:                PyList sum = null;
1083:                if (o instanceof  PySequence) {
1084:                    return null;
1085:                }
1086:                Object oList = o.__tojava__(List.class);
1087:                if (oList != Py.NoConversion && oList != null) {
1088:                    sum = new PyList();
1089:                    sum.addAll((List) oList);
1090:                    sum.extend(this );
1091:                }
1092:                return sum;
1093:            }
1094:
1095:            protected String unsupportedopMessage(String op, PyObject o2) {
1096:                if (op.equals("+")) {
1097:                    return "can only concatenate list (not \"{2}\") to list";
1098:                }
1099:                return null;
1100:            }
1101:
1102:            protected String runsupportedopMessage(String op, PyObject o2) {
1103:                if (op.equals("+")) {
1104:                    return "can only concatenate list (not \"{1}\") to list";
1105:                }
1106:                return null;
1107:            }
1108:
1109:            public String toString() {
1110:                return list_toString();
1111:            }
1112:
1113:            final String list_toString() {
1114:                ThreadState ts = Py.getThreadState();
1115:                if (!ts.enterRepr(this )) {
1116:                    return "[...]";
1117:                }
1118:
1119:                StringBuffer buf = new StringBuffer("[");
1120:                int length = size();
1121:                PyObject[] array = getArray();
1122:
1123:                for (int i = 0; i < length - 1; i++) {
1124:                    buf.append((array[i]).__repr__().toString());
1125:                    buf.append(", ");
1126:                }
1127:                if (length > 0)
1128:                    buf.append((array[length - 1]).__repr__().toString());
1129:                buf.append("]");
1130:
1131:                ts.exitRepr(this );
1132:                return buf.toString();
1133:            }
1134:
1135:            /**
1136:             * Add a single element to the end of list.
1137:             *
1138:             * @param o the element to add.
1139:             */
1140:            public void append(PyObject o) {
1141:                list_append(o);
1142:            }
1143:
1144:            final void list_append(PyObject o) {
1145:                pyadd(o);
1146:            }
1147:
1148:            /**
1149:             * Return the number elements in the list that equals the argument.
1150:             *
1151:             * @param o the argument to test for. Testing is done with
1152:             *          the <code>==</code> operator.
1153:             */
1154:            public int count(PyObject o) {
1155:                return list_count(o);
1156:            }
1157:
1158:            final int list_count(PyObject o) {
1159:                int count = 0;
1160:                PyObject[] array = getArray();
1161:                for (int i = 0, n = size(); i < n; i++) {
1162:                    if (array[i].equals(o))
1163:                        count++;
1164:                }
1165:                return count;
1166:            }
1167:
1168:            /**
1169:             * return smallest index where an element in the list equals
1170:             * the argument.
1171:             *
1172:             * @param o the argument to test for. Testing is done with
1173:             *          the <code>==</code> operator.
1174:             */
1175:            public int index(PyObject o) {
1176:                return list_index(o, 0, size());
1177:            }
1178:
1179:            public int index(PyObject o, int start) {
1180:                return list_index(o, start, size());
1181:            }
1182:
1183:            // CAU: not referenced anywheir, why is this here?
1184:            public int index(PyObject o, int start, int stop) {
1185:                return list_index(o, start, stop);
1186:            }
1187:
1188:            final int list_index(PyObject o, int start, int stop) {
1189:                return _index(o, "list.index(x): x not in list", start, stop);
1190:            }
1191:
1192:            final int list_index(PyObject o, int start) {
1193:                return _index(o, "list.index(x): x not in list", start, size());
1194:            }
1195:
1196:            final int list_index(PyObject o) {
1197:                return _index(o, "list.index(x): x not in list", 0, size());
1198:            }
1199:
1200:            private int _index(PyObject o, String message, int start, int stop) {
1201:
1202:                //Follow Python 2.3+ behavior
1203:                int validStop = calculateIndex(stop);
1204:                int validStart = calculateIndex(start);
1205:
1206:                PyObject[] array = getArray();
1207:                int i = validStart;
1208:                for (; i < validStop; i++) {
1209:                    if (array[i].equals(o))
1210:                        break;
1211:                }
1212:                if (i == validStop)
1213:                    throw Py.ValueError(message);
1214:                return i;
1215:            }
1216:
1217:            //This is closely related to fixindex in PySequence, but less strict
1218:            //fixindex returns -1 if index += length < 0 or if index >= length
1219:            //where this function returns 0 in former case and length in the latter.
1220:            //I think both are needed in different cases, but if this method turns
1221:            //out to be needed in other sequence subclasses, it should be moved to
1222:            //PySequence.
1223:            private int calculateIndex(int index) {
1224:                int length = size();
1225:                if (index < 0) {
1226:                    index = index += length;
1227:                    if (index < 0) {
1228:                        index = 0;
1229:                    }
1230:                } else if (index > length) {
1231:                    index = length;
1232:                }
1233:                return index;
1234:            }
1235:
1236:            /**
1237:             * Insert the argument element into the list at the specified
1238:             * index.
1239:             * <br>
1240:             * Same as <code>s[index:index] = [o] if index &gt;= 0</code>.
1241:             *
1242:             * @param index the position where the element will be inserted.
1243:             * @param o     the element to insert.
1244:             */
1245:            public void insert(int index, PyObject o) {
1246:                list_insert(index, o);
1247:            }
1248:
1249:            final void list_insert(int index, PyObject o) {
1250:                if (index < 0)
1251:                    index = Math.max(0, size() + index);
1252:                if (index > size())
1253:                    index = size();
1254:                list.pyadd(index, o);
1255:            }
1256:
1257:            /**
1258:             * Remove the first occurence of the argument from the list.
1259:             * The elements arecompared with the <code>==</code> operator.
1260:             * <br>
1261:             * Same as <code>del s[s.index(x)]</code>
1262:             *
1263:             * @param o the element to search for and remove.
1264:             */
1265:            public void remove(PyObject o) {
1266:                list_remove(o);
1267:            }
1268:
1269:            final void list_remove(PyObject o) {
1270:                del(_index(o, "list.remove(x): x not in list", 0, size()));
1271:            }
1272:
1273:            /**
1274:             * Reverses the items of s in place.
1275:             * The reverse() methods modify the list in place for economy
1276:             * of space when reversing a large list. It doesn't return the
1277:             * reversed list to remind you of this side effect.
1278:             */
1279:            public void reverse() {
1280:                list_reverse();
1281:            }
1282:
1283:            final void list_reverse() {
1284:                PyObject tmp;
1285:                int n = size();
1286:                PyObject[] array = getArray();
1287:                int j = n - 1;
1288:                for (int i = 0; i < n / 2; i++, j--) {
1289:                    tmp = array[i];
1290:                    array[i] = array[j];
1291:                    array[j] = tmp;
1292:                }
1293:            }
1294:
1295:            /**
1296:             * Removes and return the last element in the list.
1297:             */
1298:            public PyObject pop() {
1299:                return list_pop();
1300:            }
1301:
1302:            final PyObject list_pop() {
1303:                return pop(-1);
1304:            }
1305:
1306:            /**
1307:             * Removes and return the <code>n</code> indexed element in the
1308:             * list.
1309:             *
1310:             * @param n the index of the element to remove and return.
1311:             */
1312:            public PyObject pop(int n) {
1313:                return list_pop(n);
1314:            }
1315:
1316:            final PyObject list_pop(int n) {
1317:                int length = size();
1318:                if (length == 0) {
1319:                    throw Py.IndexError("pop from empty list");
1320:                }
1321:                if (n < 0)
1322:                    n += length;
1323:                if (n < 0 || n >= length)
1324:                    throw Py.IndexError("pop index out of range");
1325:                PyObject v = pyget(n);
1326:
1327:                setslice(n, n + 1, 1, Py.EmptyTuple);
1328:                return v;
1329:            }
1330:
1331:            /**
1332:             * Append the elements in the argument sequence to the end of the list.
1333:             * <br>
1334:             * Same as <code>s[len(s):len(s)] = o</code>.
1335:             *
1336:             * @param o the sequence of items to append to the list.
1337:             */
1338:            public void extend(PyObject o) {
1339:                list_extend(o);
1340:            }
1341:
1342:            final void list_extend(PyObject o) {
1343:                int length = size();
1344:                setslice(length, length, 1, o);
1345:            }
1346:
1347:            public PyObject __iadd__(PyObject o) {
1348:                return list___iadd__(o);
1349:            }
1350:
1351:            final PyObject list___iadd__(PyObject o) {
1352:                extend(fastSequence(o, "argument to += must be a sequence"));
1353:                return this ;
1354:            }
1355:
1356:            /**
1357:             * Sort the items of the list in place. The compare argument is a
1358:             * function of two arguments (list items) which should return
1359:             * -1, 0 or 1 depending on whether the first argument is
1360:             * considered smaller than, equal to, or larger than the second
1361:             * argument. Note that this slows the sorting process down
1362:             * considerably; e.g. to sort a list in reverse order it is much
1363:             * faster to use calls to the methods sort() and reverse() than
1364:             * to use the built-in function sort() with a comparison function
1365:             * that reverses the ordering of the elements.
1366:             *
1367:             * @param compare the comparison function.
1368:             */
1369:            public synchronized void sort(PyObject compare) {
1370:                list_sort(compare);
1371:            }
1372:
1373:            final synchronized void list_sort(PyObject compare) {
1374:                MergeState ms = new MergeState(getArray(), size(), compare);
1375:                ms.sort();
1376:            }
1377:
1378:            /**
1379:             * Sort the items of the list in place. Items is compared with the
1380:             * normal relative comparison operators.
1381:             */
1382:            public void sort() {
1383:                list_sort();
1384:            }
1385:
1386:            final void list_sort() {
1387:                list_sort(null);
1388:            }
1389:
1390:            public int hashCode() {
1391:                return list_hashCode();
1392:            }
1393:
1394:            final int list_hashCode() {
1395:                throw Py.TypeError("unhashable type");
1396:            }
1397:
1398:            /**
1399:             * Used for pickling.
1400:             *
1401:             * @return a tuple of (class, tuple)
1402:             */
1403:            public PyObject __reduce__() {
1404:                return list___reduce__();
1405:            }
1406:
1407:            final PyObject list___reduce__() {
1408:                PyTuple newargs = __getnewargs__();
1409:                return new PyTuple(new PyObject[] { getType(), newargs });
1410:            }
1411:
1412:            public PyTuple __getnewargs__() {
1413:                return new PyTuple(
1414:                        new PyObject[] { new PyTuple(list.getArray()) });
1415:            }
1416:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.