set_of_chars.h.xml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <chapter xml:id="set_of_chars.h">
  2. <title><tt>__vic/set_of_chars.h</tt></title>
  3. <chapter xml:id="set_of_chars">
  4. <title><tt>set_of_chars</tt></title>
  5. <code-block lang="C++"><![CDATA[
  6. class set_of_chars
  7. {
  8. public:
  9. constexpr set_of_chars();
  10. template<class Iter> constexpr set_of_chars(Iter begin, Iter end);
  11. constexpr set_of_chars(std::initializer_list<char> set); // C++11
  12. constexpr set_of_chars(const char *c_str);
  13. constexpr bool contains(char ch) const;
  14. constexpr void add(char ch);
  15. constexpr void remove(char ch);
  16. template<class Iter> constexpr void add(Iter begin, Iter end);
  17. constexpr void add(const char *c_str);
  18. constexpr void add(std::initializer_list<char> set); // C++11
  19. template<class Iter> void assign(Iter begin, Iter end);
  20. void assign(const char *c_str)
  21. void assign(std::initializer_list<char> set); // C++11
  22. void clear();
  23. };
  24. ]]></code-block>
  25. <p>Compact (only 32 bytes) and very fast implemetation of a set of chars. The
  26. cost of the <tt>contains()</tt> operation is always constant regardles of the
  27. argument and number of elements in the set.</p>
  28. <section><title>Class members</title>
  29. <synopsis>
  30. <prototype>constexpr set_of_chars()</prototype>
  31. <p>Creates an empty set.</p>
  32. <postcondition><tt>contains(char(ch)) == false</tt> for any char
  33. </postcondition>
  34. </synopsis>
  35. <synopsis>
  36. <prototype>template&lt;class Iter> constexpr set_of_chars(Iter begin, Iter end)</prototype>
  37. <prototype>constexpr set_of_chars(std::initializer_list&lt;char> set) <sign>C++11</sign></prototype>
  38. <p>Creates a set filled with characters from the specified range of values.</p>
  39. <note><tt>constexpr</tt> since C++14 only!</note>
  40. </synopsis>
  41. <synopsis>
  42. <prototype>constexpr set_of_chars(const char *c_str)</prototype>
  43. <p>Creates a set filled with characters from the specified C-string excluding
  44. NULL-terminator.</p>
  45. <note><tt>constexpr</tt> since C++14 only!</note>
  46. </synopsis>
  47. <synopsis>
  48. <prototype>bool contains(char ch) const</prototype>
  49. <p>Checks whether the set contains <tt>ch</tt>.</p>
  50. </synopsis>
  51. <synopsis>
  52. <prototype>constexpr void add(char ch)</prototype>
  53. <p>Adds <tt>ch</tt> to the set.</p>
  54. <postcondition><tt>contains(ch) == true</tt></postcondition>
  55. <note><tt>constexpr</tt> since C++14 only!</note>
  56. </synopsis>
  57. <synopsis>
  58. <prototype>constexpr void remove(char ch)</prototype>
  59. <p>Removes <tt>ch</tt> from the set.</p>
  60. <postcondition><tt>contains(ch) == false</tt></postcondition>
  61. <note><tt>constexpr</tt> since C++14 only!</note>
  62. </synopsis>
  63. <synopsis>
  64. <prototype>template&lt;class Iter> constexpr void add(Iter begin, Iter end)</prototype>
  65. <prototype>constexpr void add(std::initializer_list&lt;char> set) <sign>C++11</sign></prototype>
  66. <p>Calls <tt>add(ch)</tt> for each value in the range.</p>
  67. <note><tt>constexpr</tt> since C++14 only!</note>
  68. </synopsis>
  69. <synopsis>
  70. <prototype>constexpr void add(const char *c_str)</prototype>
  71. <p>Calls <tt>add(ch)</tt> for each character in the C-string excluding
  72. NULL-terminator.</p>
  73. <note><tt>constexpr</tt> since C++14 only!</note>
  74. </synopsis>
  75. <synopsis>
  76. <prototype>template&lt;class Iter> void assign(Iter begin, Iter end)</prototype>
  77. <prototype>void assign(const char *c_str)</prototype>
  78. <prototype>void assign(std::initializer_list&lt;char> set) <sign>C++11</sign></prototype>
  79. <p>Calls <tt>clear()</tt> then <tt>add()</tt> with the specified parameters.
  80. </p>
  81. </synopsis>
  82. <synopsis>
  83. <prototype>void clear()</prototype>
  84. <p>Removes all elements from the set.</p>
  85. <postcondition><tt>contains(char(ch)) == false</tt> for any char
  86. </postcondition>
  87. </synopsis>
  88. </section>
  89. </chapter>
  90. </chapter>