GNOME Bugzilla – Bug 549149
gee lacks iterate reversed
Last modified: 2019-03-20 10:36:26 UTC
Gee should have a possibility to iterate over a reversed list. foreach (sometype xyz in someGeeArrayList.reversed) { do_something; }
We will add a new prototype on the List interface: public List<G> reversed { owned get; } and implement it in ArrayList and LinkedList directly. The field backing the storage of the reversed view will be weak and handled just like _read_only_view is handled currently.
I'm working on bi-directional iterator. Implementing abstract reverse iterator on base on prev method should be trivial.
I have patches prepared (implementing reverse_view for lists). However they required additional methods (also implemented & tested but breaking interface).
Hi Maciej. Could you submit the patches ?
(In reply to comment #4) > Hi Maciej. Could you submit the patches ? You mean into git. Yes but I had discussion with Jürg today how long we are suppose to keep 0.5.x line. They would have to go into 0.7.x as they break bot ABI and API (latter for implementing List<G>).
(In reply to comment #5) > (In reply to comment #4) > > Hi Maciej. Could you submit the patches ? > > You mean into git. Yes but I had discussion with Jürg today how long we are > suppose to keep 0.5.x line. They would have to go into 0.7.x as they break bot > ABI and API (latter for implementing List<G>). For sure, that's why I said "submit" on this ticket... not to commit it :) Updating the ABI version was planned for 0.7 as part of adding the collection change signals and view APIs. List.reversed will fit well as part of that.
Created attachment 165702 [details] [review] 0001-Add-reversed-iterators.patch Currently it is 3 patches: - Add reversed iterator: Adds implementation of generic reversed iterator (may be reused for SortedMap & co.) and reversed list iterator (subclass of former) - Add reversed_index_of to List<G> interface: First break of API/ABI. Simple method that searches list from the end. last_index_of is probably better name. - Add reversed_view to List<G> interface: Actual implementation of reversed view. It contains (indirectly) tests for reversed iterators.
Created attachment 165703 [details] [review] 0002-Add-reversed_index_of-to-List-G-interface.patch
Created attachment 165704 [details] [review] 0003-Add-reversed_view-to-List-G-interface.patch
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/libgee/issues/3.