| OLD | NEW |
| 1 | 1 |
| 2 /* set object implementation | 2 /* set object implementation |
| 3 Written and maintained by Raymond D. Hettinger <python@rcn.com> | 3 Written and maintained by Raymond D. Hettinger <python@rcn.com> |
| 4 Derived from Lib/sets.py and Objects/dictobject.c. | 4 Derived from Lib/sets.py and Objects/dictobject.c. |
| 5 | 5 |
| 6 Copyright (c) 2003-2008 Python Software Foundation. | 6 Copyright (c) 2003-2008 Python Software Foundation. |
| 7 All rights reserved. | 7 All rights reserved. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 #include "Python.h" | 10 #include "Python.h" |
| (...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 736 } | 736 } |
| 737 key = entry->key; | 737 key = entry->key; |
| 738 Py_INCREF(dummy); | 738 Py_INCREF(dummy); |
| 739 entry->key = dummy; | 739 entry->key = dummy; |
| 740 so->used--; | 740 so->used--; |
| 741 so->table[0].hash = i + 1; /* next place to start */ | 741 so->table[0].hash = i + 1; /* next place to start */ |
| 742 return key; | 742 return key; |
| 743 } | 743 } |
| 744 | 744 |
| 745 PyDoc_STRVAR(pop_doc, "Remove and return an arbitrary set element.\n\ | 745 PyDoc_STRVAR(pop_doc, "Remove and return an arbitrary set element.\n\ |
| 746 Note that the element is not selected randomly,\n\ |
| 747 the exact algorithm is implementation-specific.\n\ |
| 746 Raises KeyError if the set is empty."); | 748 Raises KeyError if the set is empty."); |
| 747 | 749 |
| 748 static int | 750 static int |
| 749 set_traverse(PySetObject *so, visitproc visit, void *arg) | 751 set_traverse(PySetObject *so, visitproc visit, void *arg) |
| 750 { | 752 { |
| 751 Py_ssize_t pos = 0; | 753 Py_ssize_t pos = 0; |
| 752 setentry *entry; | 754 setentry *entry; |
| 753 | 755 |
| 754 while (set_next(so, &pos, &entry)) | 756 while (set_next(so, &pos, &entry)) |
| 755 Py_VISIT(entry->key); | 757 Py_VISIT(entry->key); |
| (...skipping 1775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2531 Py_DECREF(f); | 2533 Py_DECREF(f); |
| 2532 | 2534 |
| 2533 Py_DECREF(elem); | 2535 Py_DECREF(elem); |
| 2534 Py_DECREF(dup); | 2536 Py_DECREF(dup); |
| 2535 Py_RETURN_TRUE; | 2537 Py_RETURN_TRUE; |
| 2536 } | 2538 } |
| 2537 | 2539 |
| 2538 #undef assertRaises | 2540 #undef assertRaises |
| 2539 | 2541 |
| 2540 #endif | 2542 #endif |
| OLD | NEW |