2 * Copyright © 2012 Google, Inc.
4 * This is part of HarfBuzz, a text shaping library.
6 * Permission is hereby granted, without written agreement and without
7 * license or royalty fees, to use, copy, modify, and distribute this
8 * software and its documentation for any purpose, provided that the
9 * above copyright notice and the following two paragraphs appear in
10 * all copies of this software.
12 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
13 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
14 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
15 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
18 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
19 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
21 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
22 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
24 * Google Author(s): Behdad Esfahbod
33 * @short_description: Object representing a set of integers
36 * Set objects represent a mathematical set of integer values. They are
37 * used in non-shaping API to query certain set of characters or glyphs,
38 * or other integer values.
43 * hb_set_create: (Xconstructor)
45 * Return value: (transfer full):
54 if (!(set = hb_object_create<hb_set_t> ()))
55 return hb_set_get_empty ();
65 * Return value: (transfer full):
72 return const_cast<hb_set_t *> (&Null(hb_set_t));
76 * hb_set_reference: (skip)
79 * Return value: (transfer full):
84 hb_set_reference (hb_set_t *set)
86 return hb_object_reference (set);
90 * hb_set_destroy: (skip)
96 hb_set_destroy (hb_set_t *set)
98 if (!hb_object_destroy (set)) return;
100 set->fini_shallow ();
106 * hb_set_set_user_data: (skip)
118 hb_set_set_user_data (hb_set_t *set,
119 hb_user_data_key_t *key,
121 hb_destroy_func_t destroy,
124 return hb_object_set_user_data (set, key, data, destroy, replace);
128 * hb_set_get_user_data: (skip)
132 * Return value: (transfer none):
137 hb_set_get_user_data (hb_set_t *set,
138 hb_user_data_key_t *key)
140 return hb_object_get_user_data (set, key);
145 * hb_set_allocation_successful:
155 hb_set_allocation_successful (const hb_set_t *set)
157 return set->successful;
169 hb_set_clear (hb_set_t *set)
185 hb_set_is_empty (const hb_set_t *set)
187 return set->is_empty ();
202 hb_set_has (const hb_set_t *set,
203 hb_codepoint_t codepoint)
205 return set->has (codepoint);
218 hb_set_add (hb_set_t *set,
219 hb_codepoint_t codepoint)
221 set->add (codepoint);
235 hb_set_add_range (hb_set_t *set,
236 hb_codepoint_t first,
239 set->add_range (first, last);
252 hb_set_del (hb_set_t *set,
253 hb_codepoint_t codepoint)
255 set->del (codepoint);
269 hb_set_del_range (hb_set_t *set,
270 hb_codepoint_t first,
273 set->del_range (first, last);
283 * Return value: %TRUE if the two sets are equal, %FALSE otherwise.
288 hb_set_is_equal (const hb_set_t *set,
289 const hb_set_t *other)
291 return set->is_equal (other);
297 * @larger_set: other set.
301 * Return value: %TRUE if the @set is a subset of (or equal to) @larger_set, %FALSE otherwise.
306 hb_set_is_subset (const hb_set_t *set,
307 const hb_set_t *larger_set)
309 return set->is_subset (larger_set);
322 hb_set_set (hb_set_t *set,
323 const hb_set_t *other)
338 hb_set_union (hb_set_t *set,
339 const hb_set_t *other)
354 hb_set_intersect (hb_set_t *set,
355 const hb_set_t *other)
357 set->intersect (other);
370 hb_set_subtract (hb_set_t *set,
371 const hb_set_t *other)
373 set->subtract (other);
377 * hb_set_symmetric_difference:
386 hb_set_symmetric_difference (hb_set_t *set,
387 const hb_set_t *other)
389 set->symmetric_difference (other);
403 hb_set_invert (hb_set_t *set HB_UNUSED)
408 * hb_set_get_population:
411 * Returns the number of numbers in the set.
413 * Return value: set population.
418 hb_set_get_population (const hb_set_t *set)
420 return set->get_population ();
427 * Finds the minimum number in the set.
429 * Return value: minimum of the set, or %HB_SET_VALUE_INVALID if set is empty.
434 hb_set_get_min (const hb_set_t *set)
436 return set->get_min ();
443 * Finds the maximum number in the set.
445 * Return value: minimum of the set, or %HB_SET_VALUE_INVALID if set is empty.
450 hb_set_get_max (const hb_set_t *set)
452 return set->get_max ();
458 * @codepoint: (inout):
460 * Gets the next number in @set that is greater than current value of @codepoint.
462 * Set @codepoint to %HB_SET_VALUE_INVALID to get started.
464 * Return value: whether there was a next value.
469 hb_set_next (const hb_set_t *set,
470 hb_codepoint_t *codepoint)
472 return set->next (codepoint);
478 * @codepoint: (inout):
480 * Gets the previous number in @set that is slower than current value of @codepoint.
482 * Set @codepoint to %HB_SET_VALUE_INVALID to get started.
484 * Return value: whether there was a previous value.
489 hb_set_previous (const hb_set_t *set,
490 hb_codepoint_t *codepoint)
492 return set->previous (codepoint);
498 * @first: (out): output first codepoint in the range.
499 * @last: (inout): input current last and output last codepoint in the range.
501 * Gets the next consecutive range of numbers in @set that
502 * are greater than current value of @last.
504 * Set @last to %HB_SET_VALUE_INVALID to get started.
506 * Return value: whether there was a next range.
511 hb_set_next_range (const hb_set_t *set,
512 hb_codepoint_t *first,
513 hb_codepoint_t *last)
515 return set->next_range (first, last);
519 * hb_set_previous_range:
521 * @first: (inout): input current first and output first codepoint in the range.
522 * @last: (out): output last codepoint in the range.
524 * Gets the previous consecutive range of numbers in @set that
525 * are greater than current value of @last.
527 * Set @first to %HB_SET_VALUE_INVALID to get started.
529 * Return value: whether there was a previous range.
534 hb_set_previous_range (const hb_set_t *set,
535 hb_codepoint_t *first,
536 hb_codepoint_t *last)
538 return set->previous_range (first, last);