← Back to team overview

geda-developers team mailing list archive

Re: [RFC] edaobjectset.h (was: libgeda data structures and algorithms)

 

On Wed, Dec 19, 2012 at 11:22:32AM +0000, Peter TB Brett wrote:
> > More troublesome is that it's not obvious how eda_objectset_remove
> > and eda_objectset_iter_next interact. Does eda_objectset_remove
> > automatically advances the iterator? Does the iterator get
> > invalidated?
> 
> Yes, "remove" will make sure that the iterator is updated to point to 
> the entry after the one which was removed. That means that it's actually 
> *possible* to remove all objects that satisfy particular criteria from 
> the set in O(N) rather than O(N^2) time without making a copy of the 
> set.  For example, how would you implement the algorithm above using an 
> eda_objectset_remove() that doesn't use an iterator?

An algorithm that is O(N)? I have no idea.

> This discussion all seems a bit daft... I feel like this is exactly the 
> sort of thing that should be provided by a basic library.

Indeed it is.

-- 
Ivan Stankovic, pokemon@xxxxxxxxxxxxxx

"Protect your digital freedom and privacy, eliminate DRM, 
learn more at http://www.defectivebydesign.org/what_is_drm";


References