forked from organicmaps/organicmaps
Timsort now is compilable as C++
This commit is contained in:
parent
06c47c5715
commit
c73dc3897e
5 changed files with 27 additions and 25 deletions
|
@ -16,7 +16,7 @@ SOURCES += \
|
|||
file_container.cpp \
|
||||
bzip2_compressor.cpp \
|
||||
gzip_compressor.cpp \
|
||||
timsort/timsort.c \
|
||||
timsort/timsort.cpp \
|
||||
|
||||
|
||||
HEADERS += \
|
||||
|
@ -69,4 +69,4 @@ HEADERS += \
|
|||
coder_util.hpp \
|
||||
bzip2_compressor.hpp \
|
||||
gzip_compressor.hpp \
|
||||
timsort/timsort.h \
|
||||
timsort/timsort.hpp \
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
#include "timsort.h"
|
||||
#include "timsort.hpp"
|
||||
|
||||
#include "../../std/memcpy.hpp"
|
||||
#include "../../std/stdlib.hpp"
|
||||
|
||||
typedef int cmpFunc(const void *, const void *);
|
||||
|
||||
|
@ -676,7 +679,7 @@ static void timMergeLow(timMergeState *aState,
|
|||
*/
|
||||
timMergeGetMem(aState, aLen1);
|
||||
memcpy(aState->mMergeMem, sArray + aBase1 * sWidth, sWidth * aLen1);
|
||||
sTmp = aState->mMergeMem;
|
||||
sTmp = static_cast<uint8_t *>(aState->mMergeMem);
|
||||
|
||||
sCursor1 = 0;
|
||||
sCursor2 = aBase2;
|
||||
|
@ -896,7 +899,7 @@ static void timMergeHigh(timMergeState *aState,
|
|||
|
||||
/* Copy second run into temp memory */
|
||||
memcpy(aState->mMergeMem, sArray + aBase2 * sWidth, sWidth * aLen2);
|
||||
sTmp = aState->mMergeMem;
|
||||
sTmp = static_cast<uint8_t *>(aState->mMergeMem);
|
||||
|
||||
sCursor1 = aBase1 + aLen1 - 1;
|
||||
sCursor2 = aLen2 - 1;
|
||||
|
@ -1105,7 +1108,7 @@ static void timMergeAt(timMergeState *aState, uint32_t aWhere, cmpFunc *aCmpCb)
|
|||
* Prior elements in run1 can be ignored (because they are already in place).
|
||||
*/
|
||||
k = timGallopRight((uint8_t *)aState->mArray + sBaseB * aState->mWidth,
|
||||
aState->mArray,
|
||||
static_cast<uint8_t const *>(aState->mArray),
|
||||
aState->mWidth,
|
||||
sBaseA,
|
||||
sLenA,
|
||||
|
@ -1123,7 +1126,7 @@ static void timMergeAt(timMergeState *aState, uint32_t aWhere, cmpFunc *aCmpCb)
|
|||
* (because they are already in place).
|
||||
*/
|
||||
sLenB = timGallopLeft((uint8_t *)aState->mArray + (sBaseA + sLenA - 1) * aState->mWidth,
|
||||
aState->mArray,
|
||||
static_cast<uint8_t const *>(aState->mArray),
|
||||
aState->mWidth,
|
||||
sBaseB,
|
||||
sLenB,
|
|
@ -1,18 +0,0 @@
|
|||
#ifndef __TIM_SORT_H__
|
||||
#define __TIM_SORT_H__
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#include <stdint.h>
|
||||
#else
|
||||
typedef unsigned char uint8_t;
|
||||
typedef __int32 int32_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
void timsort(void *aArray, size_t aElementCnt, size_t aWidth, int (*aCmpCb)(const void *, const void *));
|
||||
|
||||
#endif
|
5
coding/timsort/timsort.hpp
Normal file
5
coding/timsort/timsort.hpp
Normal file
|
@ -0,0 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#include "../../std/stdint.hpp"
|
||||
|
||||
void timsort(void *aArray, size_t aElementCnt, size_t aWidth, int (*aCmpCb)(const void *, const void *));
|
12
std/stdlib.hpp
Normal file
12
std/stdlib.hpp
Normal file
|
@ -0,0 +1,12 @@
|
|||
#pragma once
|
||||
#include "common_defines.hpp"
|
||||
|
||||
#ifdef new
|
||||
#undef new
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef DEBUG_NEW
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
Loading…
Add table
Reference in a new issue