Luna::List::merge
template <typename _Compare>
void merge(List &other, _Compare comp)
Merges another list into this list.
No memory allocation or element copy/move will be performed, this function transfers elements by changing their pointers directly so that they link to the new list. Elements are compared using the user-specified comparison function object.
Parameters
-
in other
The list to merge. This list will be empty after this operation. If this is equal to
*this
, this function does nothing. -
in comp
The comparison function object to use.
Valid Usage
-
comp
must provide the following function:bool operator()(const _Ty& a, const _Ty& b)
, that returnstrue
ifa
should appear in the list beforeb
. -
Elements in
*this
andother
must be sorted in an order defined by the user-specified comparison function, that is, for any two elementsa
andb
in the same list,comp(b, a)
must returnfalse
ifa
appears beforeb
.