Migration from 0.3 to 0.5
See New and Noteworthy for more informations on the Gee 0.5 release.
Mandatory changes
Replace ReadOnly* instantiations by a call to a read_only_view property:
Use ((Collection) coll).read_only_view instead of new ReadOnlyCollection<G> (coll)
Use list.read_only_view instead of new ReadOnlyList<G> (list)
Use set.read_only_view instead of new ReadOnlySet<G> (set)
Use list.read_only_view instead of new ReadOnlyList<G> (list)
Rename Map method calls:
Use unset (key) instead of remove (key)
Use unset_all (map) instead of remove_all (map)
Use has_key (key) instead of contains (key)
Use has_all (map) instead of contains_all (key)
Note that Map.has_all (map) now checks for Map.has (key, value) for every (key,value) entries in map. (instead of Map.has_key (key))
Change get_keys () and get_values () Map methods to properties:
Use keys instead of get_keys ()
Use values instead of get_values ()
Recommended enhancements
- Use mutable iterators where possible.
- You can for instance replace such pattern:
List<int> to_be_removed = new ArrayList<int> ();
foreach (var element in list) {
if (some_condition_on (element)) {
to_be_removed.add (element);
}
}
list.remove_all (to_be_removed);- by:
Iterator<int> i = list.iterator ();
while (i.next ()) {
if (some_condition_on (i.get ())) {
i.remove ();
}
}- Use Map.entries where possible.
- You can for instance replace such pattern:
foreach (var key in map.keys) {
var value = map.get (key);
do_something_with (key, value);
}- by:
foreach (var entry in map.entries) {
do_something_with (entry.key, entry.value);
}Use static empty collections:
Use Collection.empty<G> () instead of new ReadOnlyCollection (new HashSet<G> ())
Use List.empty<G> () instead of new ReadOnlyList (new ArrayList<G> ())
Use Set.empty<G> () instead of new ReadOnlySet (new HashSet<G> ())
Use Map.empty<G> () instead of new ReadOnlyMap (new HashMap<G> ())