summaryrefslogtreecommitdiff
path: root/Source/cmAlgorithms.h
Commit message (Collapse)AuthorAgeFilesLines
* cmAlgorithms: Rename template type in cmDeleteAll algorithm.Stephen Kelly2015-02-231-10/+10
| | | | It may be any range, not only a container.
* cmAlgorithms: Add const to const objects.Stephen Kelly2015-02-231-3/+3
|
* cmAlgorithms: Add cmReverseRange adaptor.Stephen Kelly2015-02-201-0/+8
| | | | Use it to implement list(REVERSE).
* cmAlgorithms: Add cmFindNot algorithm.Stephen Kelly2015-02-201-0/+7
|
* cmAlgorithms: Update concept requirement to FowardIteratorStephen Kelly2015-02-201-6/+6
|
* cmAlgorithms: Move cmRotate out of 'implementation detail' namespace.Stephen Kelly2015-02-201-11/+11
| | | | This should be generally usable in cmake.
* cmAlgorithms: Add cmWrap.Stephen Kelly2015-02-201-0/+17
| | | | | | | | | | | | | Port some existing cmJoin to use it. cmJoin is cumbersome to use in cases where the objective is to somehow 'quote' each item and then join it with a separator. In that case, the joiner string is harder to read and reason about. cmWrap aims to solve that. Provide an overload taking char wrappers to simplify the case of surrounding every element in quotes without needing to escape the quote character.
* cmAlgorithms: Add missing const to functors.Stephen Kelly2015-02-171-3/+3
|
* cmAlgorithms: Remove sort of already-sorted container.Stephen Kelly2015-02-171-1/+0
| | | | The indices is populated by an increasing number.
* cmAlgorithms: Add cmRemoveDuplicates algorithm.Stephen Kelly2015-02-151-0/+29
| | | | | | | | | | | | | | | Start by creating a vector to hold a unique values of the input range. We expect that in most cases, there will be relatively few duplicates, so reserving enough memory for a complete copy is worthwhile. Unlike a solution involving a std::set, this algorithm allocates all the memory it needs in one go and in one place, so it is more cache friendly. Populate the unique copy with a lower_bound insert algorithm and record the indices of duplicates. This is the same complexity as the std::set insert algorithm, but without the need to allocate memory on the heap and other disadvantages of std::set. Remove the duplicates with the cmRemoveIndices algorithm.
* cmAlgorithms: Add cmRemoveMatching algorithm.Stephen Kelly2015-02-151-0/+24
| | | | | Implement it in terms of std::remove_if with a binary search through a matching range.
* cmAlgorithms: Implement algorithm for removing indexes.Stephen Kelly2015-02-151-0/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | Implement ContainerAlgorithms::RemoveN to remove N elements to the end of a container by rotating. The rotate is implemented in terms of the efficient swap algorithm, optimized even more in the standard library implementation when the compiler supports the rvalue-references feature to move elements. Implement cmRemoveN with a Range API for completeness. std::rotate in C++11 is specified to return an iterator, but c++98 specifies it to return void. libstdc++ 5.0 will be the first version to have the correct return type. Implement ContainerAlgorithms::Rotate in terms of std::rotate and return the correct iterator from it. While std::rotate requires forward iterators, this workaround means cmRotate requires bidirectional iterators. As most of CMake uses random access iterators anyway, this should not be a problem. Implement cmRemoveIndices in terms of the RemoveN algorithm, such that each element which is not removed is rotated only once. This can not use the cmRemoveN range-API algorithm because that would require creating a new range, but the range must be taken by reference and so it can't be a temporary. These remove algorithms are not part of the STL and I couldn't find them anywhere else either.
* cmAlgorithms: Add a range adaptor and API for adjusting a range.Stephen Kelly2015-02-111-0/+19
|
* cmAlgorithms: Add a Range container and adaptor method.Stephen Kelly2015-02-111-0/+21
| | | | | | | | This can make a pair of iterators API compatible with the cmJoin algorithm and other range-based algorithms. Accept different iterator types in the cmRange adaptor so that a const and non-const iterator are accepted.
* Split cmAlgorithms into a separate header file.Stephen Kelly2015-02-101-0/+151