Dazzle.FuzzyMutableIndex

Fields

None

Methods

class

new (case_sensitive)

class

new_with_free_func (case_sensitive, free_func)

begin_bulk_insert ()

contains (key)

end_bulk_insert ()

insert (key, value)

match (needle, max_matches)

ref ()

remove (key)

set_free_func (free_func)

unref ()

Details

class Dazzle.FuzzyMutableIndex
classmethod new(case_sensitive)
Parameters:

case_sensitive (bool) – True if case should be preserved.

Returns:

A newly allocated #Fuzzy that should be freed with Dazzle.FuzzyMutableIndex.unref().

Return type:

Dazzle.FuzzyMutableIndex

Create a new #Fuzzy for fuzzy matching strings.

classmethod new_with_free_func(case_sensitive, free_func)
Parameters:
Return type:

Dazzle.FuzzyMutableIndex

begin_bulk_insert()

Start a bulk insertion. self is not ready for searching until Dazzle.FuzzyMutableIndex.end_bulk_insert() has been called.

This allows for inserting large numbers of strings and deferring the final sort until Dazzle.FuzzyMutableIndex.end_bulk_insert().

contains(key)
Parameters:

key (str) –

Return type:

bool

end_bulk_insert()

Complete a bulk insert and resort the index.

insert(key, value)
Parameters:
  • key (str) – A UTF-8 encoded string.

  • value (object or None) – A value to associate with key.

Inserts a string into the fuzzy matcher.

match(needle, max_matches)
Parameters:
  • needle (str) – The needle to fuzzy search for.

  • max_matches (int) – The max number of matches to return.

Returns:

A newly allocated GLib.Array containing #FuzzyMatch elements. This should be freed when the caller is done with it using g_array_unref(). It is a programming error to keep the structure around longer than the self instance.

Return type:

[Dazzle.FuzzyMutableIndexMatch]

Dazzle.FuzzyMutableIndex searches within self for strings that fuzzy match needle. Only up to max_matches will be returned.

TODO: max_matches is not yet respected.

ref()
Return type:

Dazzle.FuzzyMutableIndex

remove(key)
Parameters:

key (str) –

set_free_func(free_func)
Parameters:

free_func (GLib.DestroyNotify) –

unref()

Decrements the reference count of fuzzy by one. When the reference count reaches zero, the structure will be freed.