1
0

🔨」 fix: fixed duplication of number

This commit is contained in:
2025-07-03 20:53:48 +02:00
parent 148a4ef839
commit d4514e6f6c

View File

@ -6,7 +6,7 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/06/04 13:28:23 by adjoly #+# #+# */
/* Updated: 2025/06/04 14:05:14 by adjoly ### ########.fr */
/* Updated: 2025/07/03 20:52:56 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
@ -43,7 +43,6 @@ template <typename Container> void printContainer(const Container &container) {
std::cout << std::endl;
}
// Measure time and run sorting for vector and deque
void sortAndTime(std::vector<int> &vec, std::deque<int> &deq) {
auto vecStart = std::clock();
_fordJohnsonSort(vec);
@ -72,7 +71,6 @@ std::vector<size_t> _generateJacobsthalOrder(size_t n) {
std::vector<size_t> sequence;
std::vector<bool> inserted(n, false);
// Generate the sequence
size_t j0 = 0, j1 = 1;
while (j1 < n) {
sequence.push_back(j1);
@ -117,10 +115,12 @@ template <typename Container> void _fordJohnsonSort(Container &container) {
_fordJohnsonSort(mainChain);
std::vector<size_t> order = _generateJacobsthalOrder(pendingElements.size());
std::vector<size_t> order =
_generateJacobsthalOrder(pendingElements.size());
for (size_t i = 0; i < order.size(); ++i) {
_binaryInsert(mainChain, pendingElements[order[i]]);
}
container = mainChain;
}
@ -136,5 +136,6 @@ template <typename Container> void _binaryInsert(Container &sorted, int value) {
itH = itMid;
}
sorted.insert(itL, value);
if (itL == sorted.end() || *itL != value)
sorted.insert(itL, value);
}