「🔨」 fix: fixed duplication of number
This commit is contained in:
@ -6,7 +6,7 @@
|
|||||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/06/04 13:28:23 by adjoly #+# #+# */
|
/* 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;
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Measure time and run sorting for vector and deque
|
|
||||||
void sortAndTime(std::vector<int> &vec, std::deque<int> &deq) {
|
void sortAndTime(std::vector<int> &vec, std::deque<int> &deq) {
|
||||||
auto vecStart = std::clock();
|
auto vecStart = std::clock();
|
||||||
_fordJohnsonSort(vec);
|
_fordJohnsonSort(vec);
|
||||||
@ -72,7 +71,6 @@ std::vector<size_t> _generateJacobsthalOrder(size_t n) {
|
|||||||
std::vector<size_t> sequence;
|
std::vector<size_t> sequence;
|
||||||
std::vector<bool> inserted(n, false);
|
std::vector<bool> inserted(n, false);
|
||||||
|
|
||||||
// Generate the sequence
|
|
||||||
size_t j0 = 0, j1 = 1;
|
size_t j0 = 0, j1 = 1;
|
||||||
while (j1 < n) {
|
while (j1 < n) {
|
||||||
sequence.push_back(j1);
|
sequence.push_back(j1);
|
||||||
@ -117,10 +115,12 @@ template <typename Container> void _fordJohnsonSort(Container &container) {
|
|||||||
|
|
||||||
_fordJohnsonSort(mainChain);
|
_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) {
|
for (size_t i = 0; i < order.size(); ++i) {
|
||||||
_binaryInsert(mainChain, pendingElements[order[i]]);
|
_binaryInsert(mainChain, pendingElements[order[i]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
container = mainChain;
|
container = mainChain;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,5 +136,6 @@ template <typename Container> void _binaryInsert(Container &sorted, int value) {
|
|||||||
itH = itMid;
|
itH = itMid;
|
||||||
}
|
}
|
||||||
|
|
||||||
sorted.insert(itL, value);
|
if (itL == sorted.end() || *itL != value)
|
||||||
|
sorted.insert(itL, value);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user