QtBase  v6.3.1
hb-set.cc
Go to the documentation of this file.
1 /*
2  * Copyright © 2012 Google, Inc.
3  *
4  * This is part of HarfBuzz, a text shaping library.
5  *
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.
11  *
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
16  * DAMAGE.
17  *
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.
23  *
24  * Google Author(s): Behdad Esfahbod
25  */
26 
27 #include "hb-set.hh"
28 
29 
51 hb_set_t *
53 {
54  hb_set_t *set;
55 
56  if (!(set = hb_object_create<hb_set_t> ()))
57  return hb_set_get_empty ();
58 
59  set->init_shallow ();
60 
61  return set;
62 }
63 
73 hb_set_t *
75 {
76  return const_cast<hb_set_t *> (&Null (hb_set_t));
77 }
78 
89 hb_set_t *
91 {
92  return hb_object_reference (set);
93 }
94 
105 void
107 {
108  if (!hb_object_destroy (set)) return;
109 
110  set->fini_shallow ();
111 
112  hb_free (set);
113 }
114 
129 hb_bool_t
132  void * data,
134  hb_bool_t replace)
135 {
136  return hb_object_set_user_data (set, key, data, destroy, replace);
137 }
138 
151 void *
154 {
155  return hb_object_get_user_data (set, key);
156 }
157 
158 
169 hb_bool_t
171 {
172  return !set->in_error ();
173 }
174 
185 hb_set_t *
187 {
188  hb_set_t *copy = hb_set_create ();
189  copy->set (*set);
190  return copy;
191 }
192 
201 void
203 {
204  /* Immutible-safe. */
205  set->clear ();
206 }
207 
218 hb_bool_t
220 {
221  return set->is_empty ();
222 }
223 
235 hb_bool_t
237  hb_codepoint_t codepoint)
238 {
239  return set->has (codepoint);
240 }
241 
251 void
253  hb_codepoint_t codepoint)
254 {
255  /* Immutible-safe. */
256  set->add (codepoint);
257 }
258 
271 HB_EXTERN void
273  const hb_codepoint_t *sorted_codepoints,
274  unsigned int num_codepoints)
275 {
276  /* Immutible-safe. */
277  set->add_sorted_array (sorted_codepoints,
278  num_codepoints,
279  sizeof(hb_codepoint_t));
280 }
281 
293 void
296  hb_codepoint_t last)
297 {
298  /* Immutible-safe. */
299  set->add_range (first, last);
300 }
301 
311 void
313  hb_codepoint_t codepoint)
314 {
315  /* Immutible-safe. */
316  set->del (codepoint);
317 }
318 
333 void
336  hb_codepoint_t last)
337 {
338  /* Immutible-safe. */
339  set->del_range (first, last);
340 }
341 
354 hb_bool_t
356  const hb_set_t *other)
357 {
358  return set->is_equal (*other);
359 }
360 
372 hb_bool_t
374  const hb_set_t *larger_set)
375 {
376  return set->is_subset (*larger_set);
377 }
378 
388 void
390  const hb_set_t *other)
391 {
392  /* Immutible-safe. */
393  set->set (*other);
394 }
395 
405 void
407  const hb_set_t *other)
408 {
409  /* Immutible-safe. */
410  set->union_ (*other);
411 }
412 
422 void
424  const hb_set_t *other)
425 {
426  /* Immutible-safe. */
427  set->intersect (*other);
428 }
429 
439 void
441  const hb_set_t *other)
442 {
443  /* Immutible-safe. */
444  set->subtract (*other);
445 }
446 
457 void
459  const hb_set_t *other)
460 {
461  /* Immutible-safe. */
462  set->symmetric_difference (*other);
463 }
464 
473 void
475 {
476  /* Immutible-safe. */
477  set->invert ();
478 }
479 
490 unsigned int
492 {
493  return set->get_population ();
494 }
495 
508 {
509  return set->get_min ();
510 }
511 
524 {
525  return set->get_max ();
526 }
527 
542 hb_bool_t
544  hb_codepoint_t *codepoint)
545 {
546  return set->next (codepoint);
547 }
548 
563 hb_bool_t
565  hb_codepoint_t *codepoint)
566 {
567  return set->previous (codepoint);
568 }
569 
586 hb_bool_t
589  hb_codepoint_t *last)
590 {
591  return set->next_range (first, last);
592 }
593 
610 hb_bool_t
613  hb_codepoint_t *last)
614 {
615  return set->previous_range (first, last);
616 }
617 
634 unsigned int
636  hb_codepoint_t codepoint,
638  unsigned int size)
639 {
640  return set->next_many (codepoint, out, size);
641 }
#define Null(Type)
Definition: hb-null.hh:106
void hb_set_add_range(hb_set_t *set, hb_codepoint_t first, hb_codepoint_t last)
Definition: hb-set.cc:294
void hb_set_add(hb_set_t *set, hb_codepoint_t codepoint)
Definition: hb-set.cc:252
hb_bool_t hb_set_is_equal(const hb_set_t *set, const hb_set_t *other)
Definition: hb-set.cc:355
void hb_set_set(hb_set_t *set, const hb_set_t *other)
Definition: hb-set.cc:389
hb_set_t * hb_set_reference(hb_set_t *set)
Definition: hb-set.cc:90
HB_EXTERN void hb_set_add_sorted_array(hb_set_t *set, const hb_codepoint_t *sorted_codepoints, unsigned int num_codepoints)
Definition: hb-set.cc:272
hb_set_t * hb_set_get_empty()
Definition: hb-set.cc:74
void hb_set_symmetric_difference(hb_set_t *set, const hb_set_t *other)
Definition: hb-set.cc:458
hb_bool_t hb_set_has(const hb_set_t *set, hb_codepoint_t codepoint)
Definition: hb-set.cc:236
hb_bool_t hb_set_previous(const hb_set_t *set, hb_codepoint_t *codepoint)
Definition: hb-set.cc:564
hb_codepoint_t hb_set_get_max(const hb_set_t *set)
Definition: hb-set.cc:523
hb_codepoint_t hb_set_get_min(const hb_set_t *set)
Definition: hb-set.cc:507
void hb_set_del(hb_set_t *set, hb_codepoint_t codepoint)
Definition: hb-set.cc:312
void hb_set_union(hb_set_t *set, const hb_set_t *other)
Definition: hb-set.cc:406
void * hb_set_get_user_data(hb_set_t *set, hb_user_data_key_t *key)
Definition: hb-set.cc:152
hb_bool_t hb_set_next_range(const hb_set_t *set, hb_codepoint_t *first, hb_codepoint_t *last)
Definition: hb-set.cc:587
hb_set_t * hb_set_create()
Definition: hb-set.cc:52
void hb_set_invert(hb_set_t *set)
Definition: hb-set.cc:474
void hb_set_subtract(hb_set_t *set, const hb_set_t *other)
Definition: hb-set.cc:440
void hb_set_destroy(hb_set_t *set)
Definition: hb-set.cc:106
hb_bool_t hb_set_is_empty(const hb_set_t *set)
Definition: hb-set.cc:219
unsigned int hb_set_next_many(const hb_set_t *set, hb_codepoint_t codepoint, hb_codepoint_t *out, unsigned int size)
Definition: hb-set.cc:635
unsigned int hb_set_get_population(const hb_set_t *set)
Definition: hb-set.cc:491
void hb_set_intersect(hb_set_t *set, const hb_set_t *other)
Definition: hb-set.cc:423
hb_set_t * hb_set_copy(const hb_set_t *set)
Definition: hb-set.cc:186
void hb_set_del_range(hb_set_t *set, hb_codepoint_t first, hb_codepoint_t last)
Definition: hb-set.cc:334
hb_bool_t hb_set_allocation_successful(const hb_set_t *set)
Definition: hb-set.cc:170
hb_bool_t hb_set_next(const hb_set_t *set, hb_codepoint_t *codepoint)
Definition: hb-set.cc:543
void hb_set_clear(hb_set_t *set)
Definition: hb-set.cc:202
hb_bool_t hb_set_is_subset(const hb_set_t *set, const hb_set_t *larger_set)
Definition: hb-set.cc:373
hb_bool_t hb_set_previous_range(const hb_set_t *set, hb_codepoint_t *first, hb_codepoint_t *last)
Definition: hb-set.cc:611
hb_bool_t hb_set_set_user_data(hb_set_t *set, hb_user_data_key_t *key, void *data, hb_destroy_func_t destroy, hb_bool_t replace)
Definition: hb-set.cc:130
#define hb_free
Definition: hb.hh:238
GLuint64 key
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint first
void(* hb_destroy_func_t)(void *user_data)
Definition: hb-common.h:771
HB_BEGIN_DECLS typedef int hb_bool_t
Definition: hb-common.h:97
uint32_t hb_codepoint_t
Definition: hb-common.h:106
#define HB_EXTERN
Definition: hb-common.h:37
HB_EXTERN hb_font_get_glyph_func_t void hb_destroy_func_t destroy
QFuture< QSet< QChar > > set
[10]
QTextStream out(stdout)
[7]
QSharedPointer< T > other(t)
[5]
void set(const hb_sparseset_t &other)
Definition: hb-set.hh:125