#20057: Add iterator to DisjointSet class
-------------------------------------+-------------------------------------
Reporter: jmantysalo | Owner:
Type: enhancement | Status: needs_info
Priority: major | Milestone: sage-7.1
Component: combinatorics | Resolution:
Keywords: | Merged in:
Authors: Jori Mäntysalo | Reviewers: Travis Scrimshaw
Report Upstream: N/A | Work issues:
Branch: | Commit:
u/jmantysalo/iterate_disjoint_set | 1f96bc01bd77eea0bd64613a97c3f41857789526
Dependencies: | Stopgaps:
-------------------------------------+-------------------------------------
Comment (by slabbe):
Thanks for allowing the discussion.
Replying to [comment:7 jmantysalo]:
> I think that `itervalues()` and not `iterkeys()` is the right solution,
if we are going to make this. There is basically no "roots" in
mathematical sense in disjoint union.
You are right. I agree. Also `iterkeys()` is not well defined as the
chosen roots might be different depending on the computer.
> So the question is about "expected to be efficient". I would vote
against it: we can make a slow iterator.
Ok. So, let `__iter__()` return
`self.root_to_elements_dict().itervalues()` then. I don't think there is
much improvement we can do by avoiding the creation of the root to
elements dict.
Positive review then :)
--
Ticket URL: <http://trac.sagemath.org/ticket/20057#comment:8>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.