From 47098daa42e663a9695c7c97f877d1a84aa53143 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Tue, 24 May 2022 11:27:32 +0200 Subject: [PATCH] Remove base/tl/algorithm.h --- CMakeLists.txt | 1 - src/base/tl/algorithm.h | 118 ---------------------------------------- 2 files changed, 119 deletions(-) delete mode 100644 src/base/tl/algorithm.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 4449e2919..6171311c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1686,7 +1686,6 @@ set_src(BASE GLOB_RECURSE src/base math.h system.cpp system.h - tl/algorithm.h tl/allocator.h tl/range.h tl/threading.h diff --git a/src/base/tl/algorithm.h b/src/base/tl/algorithm.h deleted file mode 100644 index 0ee7a8d26..000000000 --- a/src/base/tl/algorithm.h +++ /dev/null @@ -1,118 +0,0 @@ -/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ -/* If you are missing that file, acquire a complete release at teeworlds.com. */ -#ifndef BASE_TL_ALGORITHM_H -#define BASE_TL_ALGORITHM_H - -#include "base/tl/range.h" -#include -#include - -/* - insert 4 - v - 1 2 3 4 5 6 - -*/ - -template -R partition_linear(R range, T value) -{ - concept_empty::check(range); - concept_forwarditeration::check(range); - concept_sorted::check(range); - - for(; !range.empty(); range.pop_front()) - { - if(!(range.front() < value)) - return range; - } - return range; -} - -template -R partition_binary(R range, T value) -{ - concept_empty::check(range); - concept_index::check(range); - concept_size::check(range); - concept_slice::check(range); - concept_sorted::check(range); - - if(range.empty()) - return range; - if(range.back() < value) - return R(); - - while(range.size() > 1) - { - unsigned pivot = (range.size() - 1) / 2; - if(range.index(pivot) < value) - range = range.slice(pivot + 1, range.size() - 1); - else - range = range.slice(0, pivot + 1); - } - return range; -} - -template -R find_linear(R range, T value) -{ - concept_empty::check(range); - concept_forwarditeration::check(range); - for(; !range.empty(); range.pop_front()) - if(value == range.front()) - break; - return range; -} - -template -R find_binary(R range, T value) -{ - range = partition_binary(range, value); - if(range.empty()) - return range; - if(range.front() == value) - return range; - return R(); -} - -template -void sort(R range) -{ - std::stable_sort(&range.front(), &range.back() + 1); -} - -template -bool sort_verify(R range) -{ - concept_empty::check(range); - concept_forwarditeration::check(range); - - typename R::type *prev = &range.front(); - range.pop_front(); - for(; !range.empty(); range.pop_front()) - { - typename R::type *cur = &range.front(); - - if(*cur < *prev) - return false; - prev = cur; - } - - return true; -} - -template -void for_each(R range, std::function fcn) -{ - concept_empty::check(range); - concept_forwarditeration::check(range); - - for(; !range.empty(); range.pop_front()) - { - typename R::type *cur = &range.front(); - fcn(*cur); - } -} - -#endif // TL_FILE_ALGORITHMS_HPP