888
* dee_model_insert_row_sorted:
889
* @self: The model to do a sorted insert on
890
* @row_members: (array zero-terminated=1): An array of
891
* #GVariants with type signature matching those of the
892
* column schemas of @self. If any of the variants have floating
893
* references they will be consumed.
894
* @cmp_func: (scope call): Callback used for comparison or rows
895
* @user_data: (closure): Arbitrary pointer passed to @cmp_func during search
897
* Inserts a row in @self according to the sorting specified by @cmp_func.
898
* If you use this method for insertion you should not use other methods as this
899
* method assumes the model to be already sorted by @cmp_func.
901
* Returns: (transfer none) (type Dee.ModelIter): A #DeeModelIter pointing to the new row
904
dee_model_insert_row_sorted (DeeModel *self,
905
GVariant **row_members,
906
DeeCompareRowFunc cmp_func,
909
DeeModelIface *iface;
911
g_return_val_if_fail (DEE_IS_MODEL (self), NULL);
913
CHECK_SCHEMA (self, return NULL);
915
iface = DEE_MODEL_GET_IFACE (self);
917
return (* iface->insert_row_sorted) (self, row_members, cmp_func, user_data);
921
* dee_model_insert_sorted:
922
* @self: The model to do a sorted insert on
923
* @cmp_func: (scope call): Callback used for comparison or rows
924
* @user_data: (closure): Arbitrary pointer passed to @cmp_func during search
925
* @VarArgs: Specifies the row to insert. A collection of #GVariant<!-- -->s
926
* matching the number of columns @self
928
* Convenience function for calling dee_model_insert_row_sorted().
929
* Inserts a row in @self according to the sorting specified by @cmp_func.
930
* If you use this method for insertion you should not use other methods as this
931
* method assumes the model to be already sorted by @cmp_func.
933
* Returns: (transfer none) (type Dee.ModelIter): A #DeeModelIter pointing to the new row
936
dee_model_insert_sorted (DeeModel *self,
937
DeeCompareRowFunc cmp_func,
941
DeeModelIface *iface;
943
GVariant **row_members;
947
g_return_val_if_fail (DEE_IS_MODEL (self), NULL);
949
CHECK_SCHEMA (self, return NULL);
951
iface = DEE_MODEL_GET_IFACE (self);
953
/* We use the slice allocator for this and not just g_new() since we
954
* can expect a lot of allocations of the same size */
955
slice_size = dee_model_get_n_columns (self) * sizeof(gpointer);
956
row_members = g_slice_alloc (slice_size);
957
va_start (args, user_data);
958
dee_model_build_row_valist (self, row_members, &args);
961
iter = (* iface->insert_row_sorted) (self, row_members, cmp_func, user_data);
962
g_slice_free1 (slice_size, row_members);
967
* dee_model_find_row_sorted:
968
* @self: The model to do a sorted insert on
969
* @row_spec: (array zero-terminated=1): An array of
970
* #GVariants with type signature matching those of the
971
* column schemas of @self. No references will be taken on the variants.
972
* @cmp_func: (scope call): Callback used for comparison or rows
973
* @user_data: (closure): Arbitrary pointer passed to @cmp_func during search
974
* @out_was_found: (out): A place to store a boolean value that will be set when
975
* this method returns. If %TRUE then an exact match was found.
976
* If %FALSE then the returned iter points to a row just after
977
* where @row_spec would have been inserted.
978
* Pass %NULL to ignore.
980
* Finds a row in @self according to the sorting specified by @cmp_func.
981
* This method will assume that @self is already sorted by @cmp_func.
983
* If you use this method for searching you should only use
984
* dee_model_insert_row_sorted() to insert rows in the model.
986
* Returns: (transfer none) (type Dee.ModelIter): If @out_was_found is set to
987
* %TRUE then a #DeeModelIter pointing to the first matching row.
988
* If it is %FALSE then the iter pointing to the row just after where
989
* @row_spec_would have been inserted.
992
dee_model_find_row_sorted (DeeModel *self,
994
DeeCompareRowFunc cmp_func,
996
gboolean *out_was_found)
998
DeeModelIface *iface;
1000
g_return_val_if_fail (DEE_IS_MODEL (self), NULL);
1002
CHECK_SCHEMA (self, return NULL);
1004
iface = DEE_MODEL_GET_IFACE (self);
1006
return (* iface->find_row_sorted) (self, row_spec, cmp_func,
1007
user_data, out_was_found);
1011
dee_model_find_sorted (DeeModel *self,
1012
DeeCompareRowFunc cmp_func,
1014
gboolean *out_was_found,
1017
DeeModelIface *iface;
1019
GVariant **row_members;
1023
g_return_val_if_fail (DEE_IS_MODEL (self), NULL);
1025
CHECK_SCHEMA (self, return NULL);
1027
iface = DEE_MODEL_GET_IFACE (self);
1029
/* We use the slice allocator for this and not just g_new() since we
1030
* can expect a lot of allocations of the same size */
1031
slice_size = dee_model_get_n_columns (self) * sizeof(gpointer);
1032
row_members = g_slice_alloc (slice_size);
1033
va_start (args, out_was_found);
1034
dee_model_build_row_valist (self, row_members, &args);
1037
iter = (* iface->find_row_sorted) (self, row_members, cmp_func,
1038
user_data, out_was_found);
1039
g_slice_free1 (slice_size, row_members);
888
1044
* dee_model_remove:
889
1045
* @self: a #DeeModel
890
1046
* @iter: a #DeeModelIter pointing to the row to remove