summaryrefslogtreecommitdiffstats
path: root/Source/cmAlgorithms.h
Commit message (Collapse)AuthorAgeFilesLines
* Replace cmArray{Begin,End,Size} by their standard counterpartsMatthias Maennich2017-10-231-16/+61
| | | | | | | | | | | std::{begin,end} are part of C++11, std::{cbegin,cend} are part of C++14 and an standard compliant implementation has been introduced within the 'cm' namespace: cm::{cbegin,cend}. std::size is only part of C++17, hence exposing a compliant implementation within namespace cm (cm::size). where possible, the standard implementations are reused.
* Avoid using std::bind1st that is removed in C++17Brad King2017-09-231-2/+1
| | | | Use a lambda instead now that we require C++11.
* clang-format: format all code as Cpp11Daniel Pfeifer2017-08-301-1/+1
|
* server: backport to C++11Daniel Pfeifer2017-08-261-0/+19
|
* cmAlgorithms: pass std::string by const refDaniel Pfeifer2017-04-211-1/+2
|
* Use quotes for non-system includesDaniel Pfeifer2017-04-111-2/+2
| | | | | | | | | | | | | Automate with: git grep -l '#include <cm_' -- Source \ | xargs sed -i 's/#include <\(cm_.*\)>/#include "\1"/g' git grep -l '#include <cmsys/' -- Source \ | xargs sed -i 's/#include <\(cmsys\/.*\)>/#include "\1"/g' git grep -l '#include <cm[A-Z]' -- Source \ | xargs sed -i 's/#include <\(cm[A-Z].*\)>/#include "\1"/g'
* cmAlgorithms: add cmEraseIf functionDaniel Pfeifer2017-02-101-0/+6
|
* clang-tidy: apply performance-unnecessary-value-param fixesDaniel Pfeifer2016-12-121-4/+4
|
* Fix several include-what-you-use findingsDaniel Pfeifer2016-11-081-3/+11
|
* Simplify CMake per-source license noticesBrad King2016-09-271-11/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | Per-source copyright/license notice headers that spell out copyright holder names and years are hard to maintain and often out-of-date or plain wrong. Precise contributor information is already maintained automatically by the version control tool. Ultimately it is the receiver of a file who is responsible for determining its licensing status, and per-source notices are merely a convenience. Therefore it is simpler and more accurate for each source to have a generic notice of the license name and references to more detailed information on copyright holders and full license terms. Our `Copyright.txt` file now contains a list of Contributors whose names appeared source-level copyright notices. It also references version control history for more precise information. Therefore we no longer need to spell out the list of Contributors in each source file notice. Replace CMake per-source copyright/license notice headers with a short description of the license and links to `Copyright.txt` and online information available from "https://cmake.org/licensing". The online URL also handles cases of modules being copied out of our source into other projects, so we can drop our notices about replacing links with full license text. Run the `Utilities/Scripts/filter-notices.bash` script to perform the majority of the replacements mechanically. Manually fix up shebang lines and trailing newlines in a few files. Manually update the notices in a few files that the script does not handle.
* make sure to include cmConfigure.h before cmStandardIncludes.hDaniel Pfeifer2016-09-031-0/+2
|
* Ninja: Support embedding of CMake as subninja projectNicolas Despres2016-05-171-0/+15
| | | | | | Add a `CMAKE_NINJA_OUTPUT_PATH_PREFIX` variable. When it is set, CMake generates a `build.ninja` file suitable for embedding into another ninja project potentially generated by an alien generator.
* Revise C++ coding style using clang-formatKitware Robot2016-05-161-103/+113
| | | | | | | | | | | | | Run the `Utilities/Scripts/clang-format.bash` script to update all our C++ code to a new style defined by `.clang-format`. Use `clang-format` version 3.8. * If you reached this commit for a line in `git blame`, re-run the blame operation starting at the parent of this commit to see older history for the content. * See the parent commit for instructions to rebase a change across this style transition commit.
* cmAlgorithms.h: remove superfluous semicolon after methodChristoph GrĂ¼ninger2016-02-011-1/+1
|
* Remove temporary allocations when calling cmHasLiteral{Suf,Pre}fix.Milian Wolff2016-01-201-2/+2
| | | | | | | | | When the first argument passed is a std::string, we need to take it by const&, otherwise we copy the string and trigger a temporary allocation. This patch removes a few 10k temporary allocations when running the CMake daemon on the KDevelop build dir. This hotspot was found with heaptrack.
* Port CMake from cmIML to KWIMLBrad King2015-12-181-2/+2
| | | | KWIML no longer uses a configured prefix.
* cmAlgorithms: Add cmMakeReverseIterator.Stephen Kelly2015-07-221-0/+6
|
* cmAlgorithms: Add some convenient typedefs.Stephen Kelly2015-07-221-0/+6
|
* cmAlgorithms: Move Range type out of private namespace.Stephen Kelly2015-07-221-35/+35
|
* cmAlgorithms: Rename cmRange to cmMakeRange.Stephen Kelly2015-07-221-2/+2
|
* Merge topic 'cmRemoveDuplicates-improvement'Brad King2015-03-121-6/+36
|\ | | | | | | | | | | | | 8701a3f4 cmRemoveDuplicates: Partially specialize the API for pointer types. eec7091d cmRemoveDuplicates: Type-parameterize all uniq-operations 7cbafa8c cmRemoveDuplicates: Store unique iterators instead of values.
| * cmRemoveDuplicates: Partially specialize the API for pointer types.Stephen Kelly2015-03-101-1/+13
| | | | | | | | | | | | | | | | If de-duplicating a container of pointers, there is no need to store iterators to them, as that is just more 'pointer chasing'. Store the pointers themselves and use API which compares the pointers in the specialization.
| * cmRemoveDuplicates: Type-parameterize all uniq-operationsStephen Kelly2015-03-101-11/+22
| |
| * cmRemoveDuplicates: Store unique iterators instead of values.Stephen Kelly2015-03-101-6/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is no need to copy all of the values in the container in order to determine uniqueness. Iterators can be stored instead and can be used with standard algorithms with custom comparison methods. This also means that we use less space in case the value_type size is greater than sizeof(iterator). That is common for std::string which may require up to 32 bytes (libstdc++ 5.0 and MSVC at least). With libstdc++ 4.9 and older, std::string is 8 bytes, so we likely don't gain anything here. Inspired-by: Daniel Pfeifer <daniel@pfeifer-mail.de>
* | Merge topic 'cmAlgorithms-cleanup'Brad King2015-03-121-1/+1
|\ \ | |/ | | | | | | | | | | 95dd238f cmRemoveDuplicates: Fix iterator -> const_iterator. 4448f175 cmInstalledFile: Move Property implementation out of line. 7916d7ba Include cmAlgorithms where it is used.
| * cmRemoveDuplicates: Fix iterator -> const_iterator.Stephen Kelly2015-03-101-1/+1
| |
* | cmAlgorithms: Add early return in cmRemoveIndices.Stephen Kelly2015-03-101-1/+5
|/ | | | | Avoid derefencing the iterator and segfaulting if the range is empty.
* cmAlgorithms: Cache the end iterators in algorithms.Stephen Kelly2015-02-241-4/+7
|
* cmAlgorithms: Remove needless assignment.Stephen Kelly2015-02-241-2/+1
|
* cmAlgorithms: Maintain the pivot iterator in cmRemoveIndices.Stephen Kelly2015-02-241-2/+4
| | | | | Avoid the algorithm of 'Schlemiel the painter' in the case of iterators which are not RandomAccess.
* cmAlgorithms: Relax iterator requirement for cmRemoveIndices.Stephen Kelly2015-02-241-2/+5
| | | | Require only forward iterators from the range.
* cmAlgorithms: Make cmRemoveDuplicates work with more containers.Stephen Kelly2015-02-241-2/+3
| | | | | Remove the accidental requirement that the input range must be a std::vector.
* cmAlgorithms: Rename template argument to RemoveN.Stephen Kelly2015-02-241-3/+3
|
* cmAlgorithms: Relax cmRemoveN requirement to FwdIter.Stephen Kelly2015-02-241-1/+3
| | | | cmRotate already requires only FwdIter.
* cmAlgorithms: Add a size() to cmRange.Stephen Kelly2015-02-241-0/+3
| | | | | size() is already used by cmRemoveDuplicates, which is designed to accept a cmRange.
* 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