Skip to content

Commit 19d8f09

Browse files
committed
Move the documentation of public sharing map methods to the declarations
1 parent 3872df2 commit 19d8f09

File tree

1 file changed

+106
-106
lines changed

1 file changed

+106
-106
lines changed

src/util/sharing_map.h

Lines changed: 106 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -221,18 +221,61 @@ class sharing_mapt
221221
public:
222222
// interface
223223

224+
/// Erase element
225+
///
226+
/// Complexity:
227+
/// - Worst case: O(H * S + M)
228+
/// - Best case: O(H)
229+
///
230+
/// \param k: The key of the element to erase
231+
/// \param key_exists: Hint to indicate whether the element is known to exist
232+
/// (possible values `unknown` or` true`)
224233
size_type erase(const key_type &k, const tvt &key_exists = tvt::unknown());
225234

235+
/// Erase all elements
236+
///
237+
/// Complexity:
238+
/// - Worst case: O(K * (H * S + M))
239+
/// - Best case: O(K * H)
240+
///
241+
/// \param ks: The keys of the element to erase
242+
/// \param key_exists: Hint to indicate whether the elements are known to
243+
/// exist (possible values `unknown` or `true`). Applies to all elements
244+
/// (i.e., have to use `unknown` if for at least one element it is not known
245+
/// whether it exists)
226246
size_type erase_all(
227247
const keyst &ks,
228248
const tvt &key_exists = tvt::unknown()); // applies to all keys
229249

250+
/// Insert element, element must not exist in map
251+
///
252+
/// Complexity:
253+
/// - Worst case: O(H * S + M)
254+
/// - Best case: O(H)
255+
///
256+
/// \param k: The key of the element to insert
257+
/// \param m: The mapped value to insert
230258
template <class valueU>
231259
void insert(const key_type &k, valueU &&m);
232260

261+
/// Replace element, element must exist in map
262+
///
263+
/// Complexity:
264+
/// - Worst case: O(H * S + M)
265+
/// - Best case: O(H)
266+
///
267+
/// \param k: The key of the element to insert
268+
/// \param m: The mapped value to replace the old value with
233269
template <class valueU>
234270
void replace(const key_type &k, valueU &&m);
235-
271+
/// Find element
272+
///
273+
/// Complexity:
274+
/// - Worst case: O(H * log(S) + M)
275+
/// - Best case: O(H)
276+
///
277+
/// \param k: The key of the element to search
278+
/// \return optionalt containing a const reference to the value if found
236279
optionalt<std::reference_wrapper<const mapped_type>>
237280
find(const key_type &k) const;
238281

@@ -315,8 +358,51 @@ class sharing_mapt
315358
/// that are not shared between them (also see get_delta_view()).
316359
typedef std::vector<delta_view_itemt> delta_viewt;
317360

361+
/// Get a view of the elements in the map
362+
/// A view is a list of pairs with the components being const references to
363+
/// the keys and values in the map.
364+
///
365+
/// Complexity:
366+
/// - Worst case: O(N * H * log(S))
367+
/// - Best case: O(N + H)
368+
///
369+
/// \param [out] view: Empty view
318370
void get_view(viewt &view) const;
319371

372+
/// Get a delta view of the elements in the map
373+
///
374+
/// Informally, a delta view of two maps is a view of the key-value pairs in
375+
/// the maps that are contained in subtrees that are not shared between them.
376+
///
377+
/// A delta view is represented as a list of structs, with each struct having
378+
/// four members (`in_both`, `key`, `value1`, `value2`). The elements `key`,
379+
/// `value1`, and `value2` are const references to the corresponding elements
380+
/// in the map. The first element indicates whether the key exists in both
381+
/// maps, the second element is the key, the third element is the mapped value
382+
/// of the first map, and the fourth element is the mapped value of the second
383+
/// map, or a dummy element if the key exists only in the first map (in which
384+
/// case `in_both` is false).
385+
///
386+
/// Calling `A.delta_view(B, ...)` yields a view such that for each element in
387+
/// the view one of two things holds:
388+
/// - the key is contained in both A and B, and in the maps the corresponding
389+
/// key-value pairs are not contained in a subtree that is shared between
390+
/// them
391+
/// - the key is only contained in A
392+
///
393+
/// When `only_common=true`, the first case above holds for every element in
394+
/// the view.
395+
///
396+
/// Complexity:
397+
/// - Worst case: O(max(N1, N2) * H * log(S) * M1 * M2) (no sharing)
398+
/// - Best case: O(1) (maximum sharing)
399+
///
400+
/// The symbols N1, M1 refer to map A, and symbols N2, M2 refer to map B.
401+
///
402+
/// \param other: other map
403+
/// \param [out] delta_view: Empty delta view
404+
/// \param only_common: Indicates if the returned delta view should only
405+
/// contain key-value pairs for keys that exist in both maps
320406
void get_delta_view(
321407
const sharing_mapt &other,
322408
delta_viewt &delta_view,
@@ -342,13 +428,32 @@ class sharing_mapt
342428
std::size_t num_unique_leafs = 0;
343429
};
344430

431+
/// Get sharing stats
432+
///
433+
/// Complexity:
434+
/// - Worst case: O(N * H * log(S))
435+
/// - Best case: O(N + H)
436+
///
437+
/// \param begin: begin iterator
438+
/// \param end: end iterator
439+
/// \param f: function applied to the iterator to get a sharing map
440+
/// \return sharing stats
345441
template <class Iterator>
346442
static sharing_map_statst get_sharing_stats(
347443
Iterator begin,
348444
Iterator end,
349445
std::function<sharing_mapt &(const Iterator)> f =
350446
[](const Iterator it) -> sharing_mapt & { return *it; });
351447

448+
/// Get sharing stats
449+
///
450+
/// Complexity:
451+
/// - Worst case: O(N * H * log(S))
452+
/// - Best case: O(N + H)
453+
///
454+
/// \param begin: begin iterator of a map
455+
/// \param end: end iterator of a map
456+
/// \return sharing stats
352457
template <class Iterator>
353458
static sharing_map_statst get_sharing_stats_map(Iterator begin, Iterator end);
354459
#endif
@@ -549,16 +654,6 @@ ::count_unmarked_nodes(
549654
}
550655

551656
#if !defined(_MSC_VER)
552-
/// Get sharing stats
553-
///
554-
/// Complexity:
555-
/// - Worst case: O(N * H * log(S))
556-
/// - Best case: O(N + H)
557-
///
558-
/// \param begin: begin iterator
559-
/// \param end: end iterator
560-
/// \param f: function applied to the iterator to get a sharing map
561-
/// \return sharing stats
562657
SHARING_MAPT3(Iterator, , sharing_map_statst)
563658
::get_sharing_stats(
564659
Iterator begin,
@@ -604,15 +699,6 @@ ::get_sharing_stats(
604699
return sms;
605700
}
606701

607-
/// Get sharing stats
608-
///
609-
/// Complexity:
610-
/// - Worst case: O(N * H * log(S))
611-
/// - Best case: O(N + H)
612-
///
613-
/// \param begin: begin iterator of a map
614-
/// \param end: end iterator of a map
615-
/// \return sharing stats
616702
SHARING_MAPT3(Iterator, , sharing_map_statst)
617703
::get_sharing_stats_map(Iterator begin, Iterator end)
618704
{
@@ -621,15 +707,6 @@ ::get_sharing_stats_map(Iterator begin, Iterator end)
621707
}
622708
#endif
623709

624-
/// Get a view of the elements in the map
625-
/// A view is a list of pairs with the components being const references to the
626-
/// keys and values in the map.
627-
///
628-
/// Complexity:
629-
/// - Worst case: O(N * H * log(S))
630-
/// - Best case: O(N + H)
631-
///
632-
/// \param [out] view: Empty view
633710
SHARING_MAPT(void)::get_view(viewt &view) const
634711
{
635712
SM_ASSERT(view.empty());
@@ -654,39 +731,6 @@ ::gather_all(const baset &n, unsigned depth, delta_viewt &delta_view) const
654731
iterate(n, depth, f);
655732
}
656733

657-
/// Get a delta view of the elements in the map
658-
///
659-
/// Informally, a delta view of two maps is a view of the key-value pairs in the
660-
/// maps that are contained in subtrees that are not shared between them.
661-
///
662-
/// A delta view is represented as a list of structs, with each struct having
663-
/// four members (`in_both`, `key`, `value1`, `value2`). The elements `key`,
664-
/// `value1`, and `value2` are const references to the corresponding elements in
665-
/// the map. The first element indicates whether the key exists in both maps,
666-
/// the second element is the key, the third element is the mapped value of the
667-
/// first map, and the fourth element is the mapped value of the second map, or
668-
/// a dummy element if the key exists only in the first map (in which case
669-
/// `in_both` is false).
670-
///
671-
/// Calling `A.delta_view(B, ...)` yields a view such that for each element in
672-
/// the view one of two things holds:
673-
/// - the key is contained in both A and B, and in the maps the corresponding
674-
/// key-value pairs are not contained in a subtree that is shared between them
675-
/// - the key is only contained in A
676-
///
677-
/// When `only_common=true`, the first case above holds for every element in the
678-
/// view.
679-
///
680-
/// Complexity:
681-
/// - Worst case: O(max(N1, N2) * H * log(S) * M1 * M2) (no sharing)
682-
/// - Best case: O(1) (maximum sharing)
683-
///
684-
/// The symbols N1, M1 refer to map A, and symbols N2, M2 refer to map B.
685-
///
686-
/// \param other: other map
687-
/// \param [out] delta_view: Empty delta view
688-
/// \param only_common: Indicates if the returned delta view should only
689-
/// contain key-value pairs for keys that exist in both maps
690734
SHARING_MAPT(void)
691735
::get_delta_view(
692736
const sharing_mapt &other,
@@ -827,15 +871,6 @@ SHARING_MAPT2(const, innert *)::get_container_node(const key_type &k) const
827871
return ip;
828872
}
829873

830-
/// Erase element
831-
///
832-
/// Complexity:
833-
/// - Worst case: O(H * S + M)
834-
/// - Best case: O(H)
835-
///
836-
/// \param k: The key of the element to erase
837-
/// \param key_exists: Hint to indicate whether the element is known to exist
838-
/// (possible values `unknown` or` true`)
839874
SHARING_MAPT2(, size_type)::erase(const key_type &k, const tvt &key_exists)
840875
{
841876
SM_ASSERT(!key_exists.is_false());
@@ -897,17 +932,6 @@ SHARING_MAPT2(, size_type)::erase(const key_type &k, const tvt &key_exists)
897932
return 1;
898933
}
899934

900-
/// Erase all elements
901-
///
902-
/// Complexity:
903-
/// - Worst case: O(K * (H * S + M))
904-
/// - Best case: O(K * H)
905-
///
906-
/// \param ks: The keys of the element to erase
907-
/// \param key_exists: Hint to indicate whether the elements are known to exist
908-
/// (possible values `unknown` or `true`). Applies to all elements (i.e., have
909-
/// to use `unknown` if for at least one element it is not known whether it
910-
/// exists)
911935
SHARING_MAPT2(, size_type)
912936
::erase_all(const keyst &ks, const tvt &key_exists)
913937
{
@@ -921,14 +945,6 @@ ::erase_all(const keyst &ks, const tvt &key_exists)
921945
return cnt;
922946
}
923947

924-
/// Insert element, element must not exist in map
925-
///
926-
/// Complexity:
927-
/// - Worst case: O(H * S + M)
928-
/// - Best case: O(H)
929-
///
930-
/// \param k: The key of the element to insert
931-
/// \param m: The mapped value to insert
932948
SHARING_MAPT4(valueU, void)
933949
::insert(const key_type &k, valueU &&m)
934950
{
@@ -939,14 +955,6 @@ ::insert(const key_type &k, valueU &&m)
939955
num++;
940956
}
941957

942-
/// Replace element, element must exist in map
943-
///
944-
/// Complexity:
945-
/// - Worst case: O(H * S + M)
946-
/// - Best case: O(H)
947-
///
948-
/// \param k: The key of the element to insert
949-
/// \param m: The mapped value to replace the old value with
950958
SHARING_MAPT4(valueU, void)
951959
::replace(const key_type &k, valueU &&m)
952960
{
@@ -963,14 +971,6 @@ ::replace(const key_type &k, valueU &&m)
963971
lp->set_value(std::forward<valueU>(m));
964972
}
965973

966-
/// Find element
967-
///
968-
/// Complexity:
969-
/// - Worst case: O(H * log(S) + M)
970-
/// - Best case: O(H)
971-
///
972-
/// \param k: The key of the element to search
973-
/// \return optionalt containing a const reference to the value if found
974974
SHARING_MAPT2(optionalt<std::reference_wrapper<const, mapped_type>>)::find(
975975
const key_type &k) const
976976
{

0 commit comments

Comments
 (0)