001: package org.python.modules.sets;
002:
003: import java.util.Iterator;
004: import org.python.core.Py;
005: import org.python.core.PyBuiltinFunction;
006: import org.python.core.PyBuiltinMethod;
007: import org.python.core.PyBuiltinMethodNarrow;
008: import org.python.core.PyException;
009: import org.python.core.PyMethodDescr;
010: import org.python.core.PyNewWrapper;
011: import org.python.core.PyObject;
012: import org.python.core.PyString;
013: import org.python.core.PyType;
014:
015: public class PySet extends BaseSet {
016:
017: public PySet() {
018: super ();
019: }
020:
021: public PySet(PyType type) {
022: super (type);
023: }
024:
025: public PySet(PyObject data) {
026: super (data);
027:
028: }
029:
030: //~ BEGIN GENERATED REGION -- DO NOT EDIT SEE gexpose.py
031: /* type info */
032:
033: public static final String exposed_name = "Set";
034:
035: public static final Class exposed_base = PyObject.class;
036:
037: public static void typeSetup(PyObject dict, PyType.Newstyle marker) {
038: class exposed___ne__ extends PyBuiltinMethodNarrow {
039:
040: exposed___ne__(PyObject self, PyBuiltinFunction.Info info) {
041: super (self, info);
042: }
043:
044: public PyBuiltinFunction bind(PyObject self) {
045: return new exposed___ne__(self, info);
046: }
047:
048: public PyObject __call__(PyObject arg0) {
049: PyObject ret = ((PySet) self).baseset___ne__(arg0);
050: if (ret == null)
051: return Py.NotImplemented;
052: return ret;
053: }
054:
055: }
056: dict.__setitem__("__ne__", new PyMethodDescr("__ne__",
057: PySet.class, 1, 1, new exposed___ne__(null, null)));
058: class exposed___eq__ extends PyBuiltinMethodNarrow {
059:
060: exposed___eq__(PyObject self, PyBuiltinFunction.Info info) {
061: super (self, info);
062: }
063:
064: public PyBuiltinFunction bind(PyObject self) {
065: return new exposed___eq__(self, info);
066: }
067:
068: public PyObject __call__(PyObject arg0) {
069: PyObject ret = ((PySet) self).baseset___eq__(arg0);
070: if (ret == null)
071: return Py.NotImplemented;
072: return ret;
073: }
074:
075: }
076: dict.__setitem__("__eq__", new PyMethodDescr("__eq__",
077: PySet.class, 1, 1, new exposed___eq__(null, null)));
078: class exposed___or__ extends PyBuiltinMethodNarrow {
079:
080: exposed___or__(PyObject self, PyBuiltinFunction.Info info) {
081: super (self, info);
082: }
083:
084: public PyBuiltinFunction bind(PyObject self) {
085: return new exposed___or__(self, info);
086: }
087:
088: public PyObject __call__(PyObject arg0) {
089: PyObject ret = ((PySet) self).baseset___or__(arg0);
090: if (ret == null)
091: return Py.NotImplemented;
092: return ret;
093: }
094:
095: }
096: dict.__setitem__("__or__", new PyMethodDescr("__or__",
097: PySet.class, 1, 1, new exposed___or__(null, null)));
098: class exposed___xor__ extends PyBuiltinMethodNarrow {
099:
100: exposed___xor__(PyObject self, PyBuiltinFunction.Info info) {
101: super (self, info);
102: }
103:
104: public PyBuiltinFunction bind(PyObject self) {
105: return new exposed___xor__(self, info);
106: }
107:
108: public PyObject __call__(PyObject arg0) {
109: PyObject ret = ((PySet) self).baseset___xor__(arg0);
110: if (ret == null)
111: return Py.NotImplemented;
112: return ret;
113: }
114:
115: }
116: dict.__setitem__("__xor__", new PyMethodDescr("__xor__",
117: PySet.class, 1, 1, new exposed___xor__(null, null)));
118: class exposed___sub__ extends PyBuiltinMethodNarrow {
119:
120: exposed___sub__(PyObject self, PyBuiltinFunction.Info info) {
121: super (self, info);
122: }
123:
124: public PyBuiltinFunction bind(PyObject self) {
125: return new exposed___sub__(self, info);
126: }
127:
128: public PyObject __call__(PyObject arg0) {
129: PyObject ret = ((PySet) self).baseset___sub__(arg0);
130: if (ret == null)
131: return Py.NotImplemented;
132: return ret;
133: }
134:
135: }
136: dict.__setitem__("__sub__", new PyMethodDescr("__sub__",
137: PySet.class, 1, 1, new exposed___sub__(null, null)));
138: class exposed___and__ extends PyBuiltinMethodNarrow {
139:
140: exposed___and__(PyObject self, PyBuiltinFunction.Info info) {
141: super (self, info);
142: }
143:
144: public PyBuiltinFunction bind(PyObject self) {
145: return new exposed___and__(self, info);
146: }
147:
148: public PyObject __call__(PyObject arg0) {
149: PyObject ret = ((PySet) self).baseset___and__(arg0);
150: if (ret == null)
151: return Py.NotImplemented;
152: return ret;
153: }
154:
155: }
156: dict.__setitem__("__and__", new PyMethodDescr("__and__",
157: PySet.class, 1, 1, new exposed___and__(null, null)));
158: class exposed___gt__ extends PyBuiltinMethodNarrow {
159:
160: exposed___gt__(PyObject self, PyBuiltinFunction.Info info) {
161: super (self, info);
162: }
163:
164: public PyBuiltinFunction bind(PyObject self) {
165: return new exposed___gt__(self, info);
166: }
167:
168: public PyObject __call__(PyObject arg0) {
169: PyObject ret = ((PySet) self).baseset___gt__(arg0);
170: if (ret == null)
171: return Py.NotImplemented;
172: return ret;
173: }
174:
175: }
176: dict.__setitem__("__gt__", new PyMethodDescr("__gt__",
177: PySet.class, 1, 1, new exposed___gt__(null, null)));
178: class exposed___ge__ extends PyBuiltinMethodNarrow {
179:
180: exposed___ge__(PyObject self, PyBuiltinFunction.Info info) {
181: super (self, info);
182: }
183:
184: public PyBuiltinFunction bind(PyObject self) {
185: return new exposed___ge__(self, info);
186: }
187:
188: public PyObject __call__(PyObject arg0) {
189: PyObject ret = ((PySet) self).baseset___ge__(arg0);
190: if (ret == null)
191: return Py.NotImplemented;
192: return ret;
193: }
194:
195: }
196: dict.__setitem__("__ge__", new PyMethodDescr("__ge__",
197: PySet.class, 1, 1, new exposed___ge__(null, null)));
198: class exposed___le__ extends PyBuiltinMethodNarrow {
199:
200: exposed___le__(PyObject self, PyBuiltinFunction.Info info) {
201: super (self, info);
202: }
203:
204: public PyBuiltinFunction bind(PyObject self) {
205: return new exposed___le__(self, info);
206: }
207:
208: public PyObject __call__(PyObject arg0) {
209: PyObject ret = ((PySet) self).baseset___le__(arg0);
210: if (ret == null)
211: return Py.NotImplemented;
212: return ret;
213: }
214:
215: }
216: dict.__setitem__("__le__", new PyMethodDescr("__le__",
217: PySet.class, 1, 1, new exposed___le__(null, null)));
218: class exposed___lt__ extends PyBuiltinMethodNarrow {
219:
220: exposed___lt__(PyObject self, PyBuiltinFunction.Info info) {
221: super (self, info);
222: }
223:
224: public PyBuiltinFunction bind(PyObject self) {
225: return new exposed___lt__(self, info);
226: }
227:
228: public PyObject __call__(PyObject arg0) {
229: PyObject ret = ((PySet) self).baseset___lt__(arg0);
230: if (ret == null)
231: return Py.NotImplemented;
232: return ret;
233: }
234:
235: }
236: dict.__setitem__("__lt__", new PyMethodDescr("__lt__",
237: PySet.class, 1, 1, new exposed___lt__(null, null)));
238: class exposed___contains__ extends PyBuiltinMethodNarrow {
239:
240: exposed___contains__(PyObject self,
241: PyBuiltinFunction.Info info) {
242: super (self, info);
243: }
244:
245: public PyBuiltinFunction bind(PyObject self) {
246: return new exposed___contains__(self, info);
247: }
248:
249: public PyObject __call__(PyObject arg0) {
250: return Py.newBoolean(((PySet) self)
251: .baseset___contains__(arg0));
252: }
253:
254: }
255: dict.__setitem__("__contains__", new PyMethodDescr(
256: "__contains__", PySet.class, 1, 1,
257: new exposed___contains__(null, null)));
258: class exposed___deepcopy__ extends PyBuiltinMethodNarrow {
259:
260: exposed___deepcopy__(PyObject self,
261: PyBuiltinFunction.Info info) {
262: super (self, info);
263: }
264:
265: public PyBuiltinFunction bind(PyObject self) {
266: return new exposed___deepcopy__(self, info);
267: }
268:
269: public PyObject __call__(PyObject arg0) {
270: return ((PySet) self).baseset___deepcopy__(arg0);
271: }
272:
273: }
274: dict.__setitem__("__deepcopy__", new PyMethodDescr(
275: "__deepcopy__", PySet.class, 1, 1,
276: new exposed___deepcopy__(null, null)));
277: class exposed___nonzero__ extends PyBuiltinMethodNarrow {
278:
279: exposed___nonzero__(PyObject self,
280: PyBuiltinFunction.Info info) {
281: super (self, info);
282: }
283:
284: public PyBuiltinFunction bind(PyObject self) {
285: return new exposed___nonzero__(self, info);
286: }
287:
288: public PyObject __call__() {
289: return Py.newBoolean(((PySet) self)
290: .baseset___nonzero__());
291: }
292:
293: }
294: dict.__setitem__("__nonzero__", new PyMethodDescr(
295: "__nonzero__", PySet.class, 0, 0,
296: new exposed___nonzero__(null, null)));
297: class exposed_copy extends PyBuiltinMethodNarrow {
298:
299: exposed_copy(PyObject self, PyBuiltinFunction.Info info) {
300: super (self, info);
301: }
302:
303: public PyBuiltinFunction bind(PyObject self) {
304: return new exposed_copy(self, info);
305: }
306:
307: public PyObject __call__() {
308: return ((PySet) self).baseset_copy();
309: }
310:
311: }
312: dict.__setitem__("copy", new PyMethodDescr("copy", PySet.class,
313: 0, 0, new exposed_copy(null, null)));
314: class exposed_union extends PyBuiltinMethodNarrow {
315:
316: exposed_union(PyObject self, PyBuiltinFunction.Info info) {
317: super (self, info);
318: }
319:
320: public PyBuiltinFunction bind(PyObject self) {
321: return new exposed_union(self, info);
322: }
323:
324: public PyObject __call__(PyObject arg0) {
325: return ((PySet) self).baseset_union(arg0);
326: }
327:
328: }
329: dict.__setitem__("union", new PyMethodDescr("union",
330: PySet.class, 1, 1, new exposed_union(null, null)));
331: class exposed_difference extends PyBuiltinMethodNarrow {
332:
333: exposed_difference(PyObject self,
334: PyBuiltinFunction.Info info) {
335: super (self, info);
336: }
337:
338: public PyBuiltinFunction bind(PyObject self) {
339: return new exposed_difference(self, info);
340: }
341:
342: public PyObject __call__(PyObject arg0) {
343: return ((PySet) self).baseset_difference(arg0);
344: }
345:
346: }
347: dict.__setitem__("difference", new PyMethodDescr("difference",
348: PySet.class, 1, 1, new exposed_difference(null, null)));
349: class exposed_symmetric_difference extends
350: PyBuiltinMethodNarrow {
351:
352: exposed_symmetric_difference(PyObject self,
353: PyBuiltinFunction.Info info) {
354: super (self, info);
355: }
356:
357: public PyBuiltinFunction bind(PyObject self) {
358: return new exposed_symmetric_difference(self, info);
359: }
360:
361: public PyObject __call__(PyObject arg0) {
362: return ((PySet) self)
363: .baseset_symmetric_difference(arg0);
364: }
365:
366: }
367: dict.__setitem__("symmetric_difference", new PyMethodDescr(
368: "symmetric_difference", PySet.class, 1, 1,
369: new exposed_symmetric_difference(null, null)));
370: class exposed_intersection extends PyBuiltinMethodNarrow {
371:
372: exposed_intersection(PyObject self,
373: PyBuiltinFunction.Info info) {
374: super (self, info);
375: }
376:
377: public PyBuiltinFunction bind(PyObject self) {
378: return new exposed_intersection(self, info);
379: }
380:
381: public PyObject __call__(PyObject arg0) {
382: return ((PySet) self).baseset_intersection(arg0);
383: }
384:
385: }
386: dict.__setitem__("intersection", new PyMethodDescr(
387: "intersection", PySet.class, 1, 1,
388: new exposed_intersection(null, null)));
389: class exposed_issubset extends PyBuiltinMethodNarrow {
390:
391: exposed_issubset(PyObject self, PyBuiltinFunction.Info info) {
392: super (self, info);
393: }
394:
395: public PyBuiltinFunction bind(PyObject self) {
396: return new exposed_issubset(self, info);
397: }
398:
399: public PyObject __call__(PyObject arg0) {
400: return ((PySet) self).baseset_issubset(arg0);
401: }
402:
403: }
404: dict.__setitem__("issubset", new PyMethodDescr("issubset",
405: PySet.class, 1, 1, new exposed_issubset(null, null)));
406: class exposed_issuper set extends PyBuiltinMethodNarrow {
407:
408: exposed_issuper set(PyObject self,
409: PyBuiltinFunction.Info info) {
410: super (self, info);
411: }
412:
413: public PyBuiltinFunction bind(PyObject self) {
414: return new exposed_issuperset(self, info);
415: }
416:
417: public PyObject __call__(PyObject arg0) {
418: return ((PySet) self).baseset_issuper set(arg0);
419: }
420:
421: }
422: dict.__setitem__("issuperset", new PyMethodDescr("issuperset",
423: PySet.class, 1, 1, new exposed_issuperset(null, null)));
424: class exposed___len__ extends PyBuiltinMethodNarrow {
425:
426: exposed___len__(PyObject self, PyBuiltinFunction.Info info) {
427: super (self, info);
428: }
429:
430: public PyBuiltinFunction bind(PyObject self) {
431: return new exposed___len__(self, info);
432: }
433:
434: public PyObject __call__() {
435: return Py.newInteger(((PySet) self).baseset___len__());
436: }
437:
438: }
439: dict.__setitem__("__len__", new PyMethodDescr("__len__",
440: PySet.class, 0, 0, new exposed___len__(null, null)));
441: class exposed___reduce__ extends PyBuiltinMethodNarrow {
442:
443: exposed___reduce__(PyObject self,
444: PyBuiltinFunction.Info info) {
445: super (self, info);
446: }
447:
448: public PyBuiltinFunction bind(PyObject self) {
449: return new exposed___reduce__(self, info);
450: }
451:
452: public PyObject __call__() {
453: return ((PySet) self).baseset___reduce__();
454: }
455:
456: }
457: dict.__setitem__("__reduce__", new PyMethodDescr("__reduce__",
458: PySet.class, 0, 0, new exposed___reduce__(null, null)));
459: class exposed___hash__ extends PyBuiltinMethodNarrow {
460:
461: exposed___hash__(PyObject self, PyBuiltinFunction.Info info) {
462: super (self, info);
463: }
464:
465: public PyBuiltinFunction bind(PyObject self) {
466: return new exposed___hash__(self, info);
467: }
468:
469: public PyObject __call__() {
470: return Py.newInteger(((PySet) self).Set_hashCode());
471: }
472:
473: }
474: dict.__setitem__("__hash__", new PyMethodDescr("__hash__",
475: PySet.class, 0, 0, new exposed___hash__(null, null)));
476: class exposed___repr__ extends PyBuiltinMethodNarrow {
477:
478: exposed___repr__(PyObject self, PyBuiltinFunction.Info info) {
479: super (self, info);
480: }
481:
482: public PyBuiltinFunction bind(PyObject self) {
483: return new exposed___repr__(self, info);
484: }
485:
486: public PyObject __call__() {
487: return new PyString(((PySet) self).baseset_toString());
488: }
489:
490: }
491: dict.__setitem__("__repr__", new PyMethodDescr("__repr__",
492: PySet.class, 0, 0, new exposed___repr__(null, null)));
493: class exposed_add extends PyBuiltinMethodNarrow {
494:
495: exposed_add(PyObject self, PyBuiltinFunction.Info info) {
496: super (self, info);
497: }
498:
499: public PyBuiltinFunction bind(PyObject self) {
500: return new exposed_add(self, info);
501: }
502:
503: public PyObject __call__(PyObject arg0) {
504: ((PySet) self).Set_add(arg0);
505: return Py.None;
506: }
507:
508: }
509: dict.__setitem__("add", new PyMethodDescr("add", PySet.class,
510: 1, 1, new exposed_add(null, null)));
511: class exposed_remove extends PyBuiltinMethodNarrow {
512:
513: exposed_remove(PyObject self, PyBuiltinFunction.Info info) {
514: super (self, info);
515: }
516:
517: public PyBuiltinFunction bind(PyObject self) {
518: return new exposed_remove(self, info);
519: }
520:
521: public PyObject __call__(PyObject arg0) {
522: ((PySet) self).Set_remove(arg0);
523: return Py.None;
524: }
525:
526: }
527: dict.__setitem__("remove", new PyMethodDescr("remove",
528: PySet.class, 1, 1, new exposed_remove(null, null)));
529: class exposed_discard extends PyBuiltinMethodNarrow {
530:
531: exposed_discard(PyObject self, PyBuiltinFunction.Info info) {
532: super (self, info);
533: }
534:
535: public PyBuiltinFunction bind(PyObject self) {
536: return new exposed_discard(self, info);
537: }
538:
539: public PyObject __call__(PyObject arg0) {
540: ((PySet) self).Set_discard(arg0);
541: return Py.None;
542: }
543:
544: }
545: dict.__setitem__("discard", new PyMethodDescr("discard",
546: PySet.class, 1, 1, new exposed_discard(null, null)));
547: class exposed_pop extends PyBuiltinMethodNarrow {
548:
549: exposed_pop(PyObject self, PyBuiltinFunction.Info info) {
550: super (self, info);
551: }
552:
553: public PyBuiltinFunction bind(PyObject self) {
554: return new exposed_pop(self, info);
555: }
556:
557: public PyObject __call__() {
558: return ((PySet) self).Set_pop();
559: }
560:
561: }
562: dict.__setitem__("pop", new PyMethodDescr("pop", PySet.class,
563: 0, 0, new exposed_pop(null, null)));
564: class exposed_clear extends PyBuiltinMethodNarrow {
565:
566: exposed_clear(PyObject self, PyBuiltinFunction.Info info) {
567: super (self, info);
568: }
569:
570: public PyBuiltinFunction bind(PyObject self) {
571: return new exposed_clear(self, info);
572: }
573:
574: public PyObject __call__() {
575: ((PySet) self).Set_clear();
576: return Py.None;
577: }
578:
579: }
580: dict.__setitem__("clear", new PyMethodDescr("clear",
581: PySet.class, 0, 0, new exposed_clear(null, null)));
582: class exposed_update extends PyBuiltinMethodNarrow {
583:
584: exposed_update(PyObject self, PyBuiltinFunction.Info info) {
585: super (self, info);
586: }
587:
588: public PyBuiltinFunction bind(PyObject self) {
589: return new exposed_update(self, info);
590: }
591:
592: public PyObject __call__(PyObject arg0) {
593: ((PySet) self).Set_update(arg0);
594: return Py.None;
595: }
596:
597: }
598: dict.__setitem__("update", new PyMethodDescr("update",
599: PySet.class, 1, 1, new exposed_update(null, null)));
600: class exposed_union_update extends PyBuiltinMethodNarrow {
601:
602: exposed_union_update(PyObject self,
603: PyBuiltinFunction.Info info) {
604: super (self, info);
605: }
606:
607: public PyBuiltinFunction bind(PyObject self) {
608: return new exposed_union_update(self, info);
609: }
610:
611: public PyObject __call__(PyObject arg0) {
612: ((PySet) self).Set_union_update(arg0);
613: return Py.None;
614: }
615:
616: }
617: dict.__setitem__("union_update", new PyMethodDescr(
618: "union_update", PySet.class, 1, 1,
619: new exposed_union_update(null, null)));
620: class exposed_intersection_update extends PyBuiltinMethodNarrow {
621:
622: exposed_intersection_update(PyObject self,
623: PyBuiltinFunction.Info info) {
624: super (self, info);
625: }
626:
627: public PyBuiltinFunction bind(PyObject self) {
628: return new exposed_intersection_update(self, info);
629: }
630:
631: public PyObject __call__(PyObject arg0) {
632: ((PySet) self).Set_intersection_update(arg0);
633: return Py.None;
634: }
635:
636: }
637: dict.__setitem__("intersection_update", new PyMethodDescr(
638: "intersection_update", PySet.class, 1, 1,
639: new exposed_intersection_update(null, null)));
640: class exposed_symmetric_difference_update extends
641: PyBuiltinMethodNarrow {
642:
643: exposed_symmetric_difference_update(PyObject self,
644: PyBuiltinFunction.Info info) {
645: super (self, info);
646: }
647:
648: public PyBuiltinFunction bind(PyObject self) {
649: return new exposed_symmetric_difference_update(self,
650: info);
651: }
652:
653: public PyObject __call__(PyObject arg0) {
654: ((PySet) self).Set_symmetric_difference_update(arg0);
655: return Py.None;
656: }
657:
658: }
659: dict.__setitem__("symmetric_difference_update",
660: new PyMethodDescr("symmetric_difference_update",
661: PySet.class, 1, 1,
662: new exposed_symmetric_difference_update(null,
663: null)));
664: class exposed_difference_update extends PyBuiltinMethodNarrow {
665:
666: exposed_difference_update(PyObject self,
667: PyBuiltinFunction.Info info) {
668: super (self, info);
669: }
670:
671: public PyBuiltinFunction bind(PyObject self) {
672: return new exposed_difference_update(self, info);
673: }
674:
675: public PyObject __call__(PyObject arg0) {
676: ((PySet) self).Set_difference_update(arg0);
677: return Py.None;
678: }
679:
680: }
681: dict.__setitem__("difference_update", new PyMethodDescr(
682: "difference_update", PySet.class, 1, 1,
683: new exposed_difference_update(null, null)));
684: class exposed__as_immutable extends PyBuiltinMethodNarrow {
685:
686: exposed__as_immutable(PyObject self,
687: PyBuiltinFunction.Info info) {
688: super (self, info);
689: }
690:
691: public PyBuiltinFunction bind(PyObject self) {
692: return new exposed__as_immutable(self, info);
693: }
694:
695: public PyObject __call__() {
696: return ((PySet) self).Set__as_immutable();
697: }
698:
699: }
700: dict.__setitem__("_as_immutable", new PyMethodDescr(
701: "_as_immutable", PySet.class, 0, 0,
702: new exposed__as_immutable(null, null)));
703: class exposed___init__ extends PyBuiltinMethod {
704:
705: exposed___init__(PyObject self, PyBuiltinFunction.Info info) {
706: super (self, info);
707: }
708:
709: public PyBuiltinFunction bind(PyObject self) {
710: return new exposed___init__(self, info);
711: }
712:
713: public PyObject __call__(PyObject[] args) {
714: return __call__(args, Py.NoKeywords);
715: }
716:
717: public PyObject __call__(PyObject[] args, String[] keywords) {
718: ((PySet) self).Set_init(args, keywords);
719: return Py.None;
720: }
721:
722: }
723: dict.__setitem__("__init__", new PyMethodDescr("__init__",
724: PySet.class, -1, -1, new exposed___init__(null, null)));
725: dict.__setitem__("__new__", new PyNewWrapper(PySet.class,
726: "__new__", -1, -1) {
727:
728: public PyObject new_impl(boolean init, PyType subtype,
729: PyObject[] args, String[] keywords) {
730: PySet newobj;
731: if (for_type == subtype) {
732: newobj = new PySet();
733: if (init)
734: newobj.Set_init(args, keywords);
735: } else {
736: newobj = new PySetDerived(subtype);
737: }
738: return newobj;
739: }
740:
741: });
742: }
743:
744: //~ END GENERATED REGION -- DO NOT EDIT SEE gexpose.py
745:
746: final void Set_init(PyObject[] args, String[] kwds) {
747: int nargs = args.length - kwds.length;
748: if (nargs > 1) {
749: throw PyBuiltinFunction.DefaultInfo.unexpectedCall(nargs,
750: false, exposed_name, 0, 1);
751: }
752: if (nargs == 0) {
753: return;
754: }
755:
756: PyObject o = args[0];
757: _update(o);
758: }
759:
760: public PyObject __ior__(PyObject other) {
761: return Set___ior__(other);
762: }
763:
764: final PyObject Set___ior__(PyObject other) {
765: BaseSet bs = this ._binary_sanity_check(other);
766: this ._set.addAll(bs._set);
767: return this ;
768: }
769:
770: public PyObject __ixor__(PyObject other) {
771: return Set___ixor__(other);
772: }
773:
774: final PyObject Set___ixor__(PyObject other) {
775: this ._binary_sanity_check(other);
776: Set_symmetric_difference_update(other);
777: return this ;
778: }
779:
780: public PyObject __iand__(PyObject other) {
781: return Set___iand__(other);
782: }
783:
784: final PyObject Set___iand__(PyObject other) {
785: BaseSet bs = this ._binary_sanity_check(other);
786: this ._set = ((BaseSet) this .__and__(bs))._set;
787: return this ;
788: }
789:
790: public PyObject __isub__(PyObject other) {
791: return Set___isub__(other);
792: }
793:
794: final PyObject Set___isub__(PyObject other) {
795: BaseSet bs = this ._binary_sanity_check(other);
796: this ._set.removeAll(bs._set);
797: return this ;
798: }
799:
800: public int hashCode() {
801: return Set_hashCode();
802: }
803:
804: final int Set_hashCode() {
805: throw Py.TypeError("Can't hash a Set, only an ImmutableSet.");
806: }
807:
808: final void Set_add(PyObject o) {
809: try {
810: this ._set.add(o);
811: } catch (PyException e) {
812: PyObject immutable = this .asImmutable(e, o);
813: this ._set.add(immutable);
814: }
815: }
816:
817: final void Set_remove(PyObject o) {
818: boolean b = false;
819: try {
820: b = this ._set.remove(o);
821: } catch (PyException e) {
822: PyObject immutable = this .asImmutable(e, o);
823: b = this ._set.remove(immutable);
824: }
825: if (!b) {
826: throw new PyException(Py.LookupError, o.toString());
827: }
828: }
829:
830: final void Set_discard(PyObject o) {
831: try {
832: this ._set.remove(o);
833: } catch (PyException e) {
834: PyObject immutable = this .asImmutable(e, o);
835: this ._set.remove(immutable);
836: }
837: }
838:
839: final PyObject Set_pop() {
840: Iterator iterator = this ._set.iterator();
841: Object first = iterator.next();
842: this ._set.remove(first);
843: return (PyObject) first;
844: }
845:
846: final void Set_clear() {
847: this ._set.clear();
848: }
849:
850: final void Set_update(PyObject data) {
851: this ._update(data);
852: }
853:
854: final void Set_union_update(PyObject other) {
855: this ._update(other);
856: }
857:
858: final void Set_intersection_update(PyObject other) {
859: if (other instanceof BaseSet) {
860: this .__iand__(other);
861: } else {
862: BaseSet set = (BaseSet) baseset_intersection(other);
863: this ._set = set._set;
864: }
865: }
866:
867: final void Set_symmetric_difference_update(PyObject other) {
868: BaseSet bs = (other instanceof BaseSet) ? (BaseSet) other
869: : new PySet(other);
870: for (Iterator iterator = bs._set.iterator(); iterator.hasNext();) {
871: Object o = iterator.next();
872: if (this ._set.contains(o)) {
873: this ._set.remove(o);
874: } else {
875: this ._set.add(o);
876: }
877: }
878: }
879:
880: final void Set_difference_update(PyObject other) {
881: if (other instanceof BaseSet) {
882: this .__isub__(other);
883: return;
884: }
885: PyObject iter = other.__iter__();
886: for (PyObject o; (o = iter.__iternext__()) != null;) {
887: if (this .__contains__(o)) {
888: this ._set.remove(o);
889: }
890: }
891: }
892:
893: final PyObject Set__as_immutable() {
894: return new PyImmutableSet(this);
895: }
896: }
|