This helps in our quest to get rid of HashTable.
Helps: bgo#640092
Map<Individual, Map<Individual, MatchResult>>
* IndividualAggregator.get_potential_matches() now returns a
Map<Individual, MatchResult>
+* IndividualAggregator.individuals now has type Map<string, Individual>
Overview of changes from libfolks 0.4.0 to libfolks 0.5.0
=========================================================
}
/**
- * A table mapping {@link Individual.id}s to their {@link Individual}s.
+ * A map from {@link Individual.id}s to their {@link Individual}s.
*
* This is the canonical set of {@link Individual}s provided by this
* IndividualAggregator.
* {@link Individual}s may be added or removed using
* {@link IndividualAggregator.add_persona_from_details} and
* {@link IndividualAggregator.remove_individual}, respectively.
+ *
+ * @since UNRELEASED
*/
- public HashTable<string, Individual> individuals { get; private set; }
+ public Map<string, Individual> individuals { get; private set; }
/**
* The {@link Individual} representing the user.
public IndividualAggregator ()
{
this._stores = new HashMap<string, PersonaStore> ();
- this.individuals = new HashTable<string, Individual> (str_hash,
- str_equal);
+ this.individuals = new HashMap<string, Individual> ();
this._link_map = new HashTable<string, Individual> (str_hash, str_equal);
this._backends = new HashSet<Backend> ();
new HashMap<Individual, MatchResult> ();
Folks.PotentialMatch matchObj = new Folks.PotentialMatch ();
- foreach (var i in this.individuals.get_values ())
+ foreach (var i in this.individuals.values)
{
if (i.id == matchee.id)
continue;
{
HashMap<Individual, HashMap<Individual, MatchResult>> matches =
new HashMap<Individual, HashMap<Individual, MatchResult>> ();
- GLib.List<Individual> individuals = this.individuals.get_values ();
+ var individuals = this.individuals.values.to_array ();
Folks.PotentialMatch matchObj = new Folks.PotentialMatch ();
- for (unowned GLib.List<Individual> l = individuals;
- l != null && l.next != null; l = l.next)
+ for (var i = 0; i < individuals.length; i++)
{
- var a = l.data;
+ var a = individuals[i];
var matches_a = matches.get (a);
if (matches_a == null)
{
matches.set (a, matches_a);
}
- for (unowned GLib.List<Individual> j=l.next; j != null; j = j.next)
+ for (var f = i + 1; f < individuals.length; f++)
{
- var b = j.data;
+ var b = individuals[f];
var matches_b = matches.get (b);
if (matches_b == null)
{
/* Add the new Individual to the aggregator */
i.removed.connect (this._individual_removed_cb);
added_individuals.add (i);
- this.individuals.insert (i.id, i);
+ this.individuals.set (i.id, i);
}
}
foreach (var individual in removed_individuals)
{
/* Ensure we don't remove the same Individual twice */
- if (this.individuals.lookup (individual.id) == null)
+ if (this.individuals.has_key (individual.id) == false)
continue;
debug (" %s", individual.id);
if (user == individual)
user = null;
- this.individuals.remove (individual.id);
+ this.individuals.unset (individual.id);
individual.personas = null;
}
/* Only signal if the individual is still in this.individuals. This allows
* us to group removals together in, e.g., _personas_changed_cb(). */
- if (this.individuals.lookup (i.id) != i)
+ if (this.individuals.get (i.id) != i)
return;
var individuals = new HashSet<Individual> ();
individuals, null, null, 0);
}
- this.individuals.remove (i.id);
+ this.individuals.unset (i.id);
}
/**
private void _notify_full_name_cb ()
{
- GLib.List<Individual> individuals =
- this._aggregator.individuals.get_values ();
- foreach (unowned Individual i in individuals)
+ var individuals = this._aggregator.individuals.values;
+ foreach (var i in individuals)
{
if (i.full_name == this._persona_fullname)
{
private void _notify_avatar_cb ()
{
- var i = this._aggregator.individuals.lookup (this._individual_id);
+ var i = this._aggregator.individuals.get (this._individual_id);
if (i == null)
return;
bool initial_email_found_again = false;
- var i = this._aggregator.individuals.lookup (this._individual_id);
+ var i = this._aggregator.individuals.get (this._individual_id);
if (i != null)
{
foreach (var fd in i.email_addresses)
private void _try_match_all ()
{
- var ind1 = this._aggregator.individuals.lookup (this._individual_id_1);
+ var ind1 = this._aggregator.individuals.get (this._individual_id_1);
var matches_1 = this._aggregator.get_potential_matches (ind1,
MatchResult.MEDIUM);
this._matches_1 = matches_1.size;
private void _try_potential_match ()
{
- var ind1 = this._aggregator.individuals.lookup (this._individual_id_1);
- var ind2 = this._aggregator.individuals.lookup (this._individual_id_2);
+ var ind1 = this._aggregator.individuals.get (this._individual_id_1);
+ var ind2 = this._aggregator.individuals.get (this._individual_id_2);
Folks.PotentialMatch matchObj = new Folks.PotentialMatch ();
this._match = matchObj.potential_match (ind1, ind2);
private void _try_potential_match ()
{
- var ind1 = this._aggregator.individuals.lookup (this._individual_id_1);
- var ind2 = this._aggregator.individuals.lookup (this._individual_id_2);
+ var ind1 = this._aggregator.individuals.get (this._individual_id_1);
+ var ind2 = this._aggregator.individuals.get (this._individual_id_2);
Folks.PotentialMatch matchObj = new Folks.PotentialMatch ();
this._match = matchObj.potential_match (ind1, ind2);
private void _try_potential_match ()
{
- var ind1 = this._aggregator.individuals.lookup (this._individual_id_1);
- var ind2 = this._aggregator.individuals.lookup (this._individual_id_2);
+ var ind1 = this._aggregator.individuals.get (this._individual_id_1);
+ var ind2 = this._aggregator.individuals.get (this._individual_id_2);
Folks.PotentialMatch matchObj = new Folks.PotentialMatch ();
this._match = matchObj.potential_match (ind1, ind2);
private void _try_potential_match ()
{
- var ind1 = this._aggregator.individuals.lookup (this._individual_id_1);
- var ind2 = this._aggregator.individuals.lookup (this._individual_id_2);
+ var ind1 = this._aggregator.individuals.get (this._individual_id_1);
+ var ind2 = this._aggregator.individuals.get (this._individual_id_2);
Folks.PotentialMatch matchObj = new Folks.PotentialMatch ();
this._match = matchObj.potential_match (ind1, ind2);
private void _try_potential_match ()
{
- var ind1 = this._aggregator.individuals.lookup (this._individual_id_1);
- var ind2 = this._aggregator.individuals.lookup (this._individual_id_2);
+ var ind1 = this._aggregator.individuals.get (this._individual_id_1);
+ var ind2 = this._aggregator.individuals.get (this._individual_id_2);
Folks.PotentialMatch matchObj = new Folks.PotentialMatch ();
this._match = matchObj.potential_match (ind1, ind2);
if (command_string == null)
{
/* List all the individuals */
- this.client.aggregator.individuals.foreach ((k, v) =>
+ foreach (var individual in this.client.aggregator.individuals.values)
{
- Utils.print_individual ((Individual) v, false);
+ Utils.print_individual (individual, false);
Utils.print_line ("");
- });
+ }
}
else
{
/* Display the details of a single individual */
- Individual individual =
- this.client.aggregator.individuals.lookup (command_string);
+ var individual =
+ this.client.aggregator.individuals.get (command_string);
if (individual == null)
{
public override void run (string? command_string)
{
- this.client.aggregator.individuals.foreach ((k, v) =>
+ foreach (var individual in this.client.aggregator.individuals.values)
{
- Individual individual = (Individual) v;
-
foreach (Persona persona in individual.personas)
{
/* Either list all personas, or only list the one specified */
if (command_string == null)
Utils.print_line ("");
}
- });
+ }
}
public override string[]? complete_subcommand (string subcommand)
/* FIXME: This can't be in the individual_id_completion_cb() function because
* Vala doesn't allow static local variables. Erk. */
- private static HashTableIter<string, Individual>? individual_id_iter = null;
+ private static MapIterator<string, Individual>? individual_id_iter = null;
/* Complete an individual's ID, starting with @word. */
public static string? individual_id_completion_cb (string word,
/* Initialise state. Whoever wrote the readline API should be shot. */
if (state == 0)
{
- Utils.individual_id_iter = HashTableIter<string, Individual> (
- main_client.aggregator.individuals);
+ Utils.individual_id_iter =
+ main_client.aggregator.individuals.map_iterator ();
}
- string id;
- Individual individual;
- while (Utils.individual_id_iter.next (out id, out individual) == true)
+ while (Utils.individual_id_iter.next () == true)
{
+ var id = Utils.individual_id_iter.get_key ();
if (id.has_prefix (word))
return id;
}
/* Initialise state. Whoever wrote the readline API should be shot. */
if (state == 0)
{
- Utils.individual_id_iter = HashTableIter<string, Individual> (
- main_client.aggregator.individuals);
+ Utils.individual_id_iter =
+ main_client.aggregator.individuals.map_iterator ();
Utils.persona_uid_iter = null;
}
- Individual individual = null;
while (Utils.persona_uid_iter != null ||
- Utils.individual_id_iter.next (null, out individual) == true)
+ Utils.individual_id_iter.next () == true)
{
+ var individual = Utils.individual_id_iter.get_value ();
+
if (Utils.persona_uid_iter == null)
{
assert (individual != null);