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
27 #include "hb-set-private.hh"
34 * hb_set_create: (Xconstructor)
36 * Return value: (transfer full):
45 if (!(set = hb_object_create<hb_set_t> ()))
46 return hb_set_get_empty ();
53 static const hb_set_t _hb_set_nil = {
54 HB_OBJECT_HEADER_STATIC,
63 * Return value: (transfer full):
68 hb_set_get_empty (void)
70 return const_cast<hb_set_t *> (&_hb_set_nil);
74 * hb_set_reference: (skip)
77 * Return value: (transfer full):
82 hb_set_reference (hb_set_t *set)
84 return hb_object_reference (set);
88 * hb_set_destroy: (skip)
94 hb_set_destroy (hb_set_t *set)
96 if (!hb_object_destroy (set)) return;
104 * hb_set_set_user_data: (skip)
116 hb_set_set_user_data (hb_set_t *set,
117 hb_user_data_key_t *key,
119 hb_destroy_func_t destroy,
122 return hb_object_set_user_data (set, key, data, destroy, replace);
126 * hb_set_get_user_data: (skip)
130 * Return value: (transfer none):
135 hb_set_get_user_data (hb_set_t *set,
136 hb_user_data_key_t *key)
138 return hb_object_get_user_data (set, key);
143 * hb_set_allocation_successful:
153 hb_set_allocation_successful (const hb_set_t *set HB_UNUSED)
155 return !set->in_error;
167 hb_set_clear (hb_set_t *set)
183 hb_set_is_empty (const hb_set_t *set)
185 return set->is_empty ();
200 hb_set_has (const hb_set_t *set,
201 hb_codepoint_t codepoint)
203 return set->has (codepoint);
216 hb_set_add (hb_set_t *set,
217 hb_codepoint_t codepoint)
219 set->add (codepoint);
233 hb_set_add_range (hb_set_t *set,
234 hb_codepoint_t first,
237 set->add_range (first, last);
250 hb_set_del (hb_set_t *set,
251 hb_codepoint_t codepoint)
253 set->del (codepoint);
267 hb_set_del_range (hb_set_t *set,
268 hb_codepoint_t first,
271 set->del_range (first, last);
286 hb_set_is_equal (const hb_set_t *set,
287 const hb_set_t *other)
289 return set->is_equal (other);
302 hb_set_set (hb_set_t *set,
303 const hb_set_t *other)
318 hb_set_union (hb_set_t *set,
319 const hb_set_t *other)
334 hb_set_intersect (hb_set_t *set,
335 const hb_set_t *other)
337 set->intersect (other);
350 hb_set_subtract (hb_set_t *set,
351 const hb_set_t *other)
353 set->subtract (other);
357 * hb_set_symmetric_difference:
366 hb_set_symmetric_difference (hb_set_t *set,
367 const hb_set_t *other)
369 set->symmetric_difference (other);
383 hb_set_invert (hb_set_t *set)
388 * hb_set_get_population:
391 * Returns the number of numbers in the set.
393 * Return value: set population.
398 hb_set_get_population (const hb_set_t *set)
400 return set->get_population ();
407 * Finds the minimum number in the set.
409 * Return value: minimum of the set, or %HB_SET_VALUE_INVALID if set is empty.
414 hb_set_get_min (const hb_set_t *set)
416 return set->get_min ();
423 * Finds the maximum number in the set.
425 * Return value: minimum of the set, or %HB_SET_VALUE_INVALID if set is empty.
430 hb_set_get_max (const hb_set_t *set)
432 return set->get_max ();
438 * @codepoint: (inout):
440 * Gets the next number in @set that is greater than current value of @codepoint.
442 * Set @codepoint to %HB_SET_VALUE_INVALID to get started.
444 * Return value: whether there was a next value.
449 hb_set_next (const hb_set_t *set,
450 hb_codepoint_t *codepoint)
452 return set->next (codepoint);
458 * @codepoint: (inout):
460 * Gets the previous number in @set that is slower than current value of @codepoint.
462 * Set @codepoint to %HB_SET_VALUE_INVALID to get started.
464 * Return value: whether there was a previous value.
469 hb_set_previous (const hb_set_t *set,
470 hb_codepoint_t *codepoint)
472 return set->previous (codepoint);
478 * @first: (out): output first codepoint in the range.
479 * @last: (inout): input current last and output last codepoint in the range.
481 * Gets the next consecutive range of numbers in @set that
482 * are greater than current value of @last.
484 * Set @last to %HB_SET_VALUE_INVALID to get started.
486 * Return value: whether there was a next range.
491 hb_set_next_range (const hb_set_t *set,
492 hb_codepoint_t *first,
493 hb_codepoint_t *last)
495 return set->next_range (first, last);
499 * hb_set_previous_range:
501 * @first: (inout): input current first and output first codepoint in the range.
502 * @last: (out): output last codepoint in the range.
504 * Gets the previous consecutive range of numbers in @set that
505 * are greater than current value of @last.
507 * Set @first to %HB_SET_VALUE_INVALID to get started.
509 * Return value: whether there was a previous range.
514 hb_set_previous_range (const hb_set_t *set,
515 hb_codepoint_t *first,
516 hb_codepoint_t *last)
518 return set->previous_range (first, last);