1 # ifndef CPPAD_UTILITY_INDEX_SORT_HPP
2 # define CPPAD_UTILITY_INDEX_SORT_HPP
92 template <
class Compare>
139 template <
class VectorKey,
class VectorSize>
142 CheckSimpleVector<size_t, VectorSize>();
147 size_t(keys.size()) ==
size_t(ind.size()),
148 "index_sort: vector sizes do not match"
151 size_t size_work = size_t(keys.size());
154 thread_alloc::create_array<element>(size_work, size_out);
158 for(i = 0; i < size_work; i++)
159 { work[i].set_key( keys[i] );
160 work[i].set_index( i );
164 std::sort(work, work+size_work);
167 for(i = 0; i < size_work; i++)
168 ind[i] = work[i].get_index();
void set_index(const size_t &index)
set the index for this element
#define CPPAD_ASSERT_KNOWN(exp, msg)
Check that exp is true, if not print msg and terminate execution.
Define processor symbols and macros that are used by CppAD.
size_t get_index(void) const
get the index for this element
static void delete_array(Type *array)
Return Memory Used for an Array to the Available Pool (include destructor call for each element)...
void index_sort(const VectorKey &keys, VectorSize &ind)
Compute the indices that sort a vector of keys.
Compare get_key(void) const
get the key for this element
Helper class used by index_sort.
bool operator<(const index_sort_element &other) const
operator requried by std::sort
Compare key_
key used to determine position of this element
size_t index_
index vlaue corresponding to this key
File used to define the CppAD multi-threading allocator class.
void set_key(const Compare &value)
set the key for this element