integer
This commit is contained in:
commit
59826852e4
11
main.cpp
Normal file
11
main.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
// g++ main.cpp -o main
|
||||
|
||||
#include<cstdio>
|
||||
#include<cstdint>
|
||||
#include"turbolist.h"
|
||||
|
||||
int main() {
|
||||
TurboList list(4);
|
||||
printf("sizeof(int)> %d\n", sizeof(int));
|
||||
return 0;
|
||||
}
|
4
makefile
Normal file
4
makefile
Normal file
@ -0,0 +1,4 @@
|
||||
debug:
|
||||
g++ main.cpp -o main
|
||||
release:
|
||||
g++ main.cpp -O2 main
|
28
turbolist.h
Normal file
28
turbolist.h
Normal file
@ -0,0 +1,28 @@
|
||||
#include<cstdint>
|
||||
#include<cstdlib>
|
||||
|
||||
class TurboList {
|
||||
int *old;
|
||||
int *nex;
|
||||
|
||||
uint32_t mid; // non-inclusive . . . m
|
||||
uint32_t end; // non-inclusive e . . . .
|
||||
|
||||
uint32_t capacity;
|
||||
uint32_t count;
|
||||
public:
|
||||
inline TurboList(uint32_t cap) noexcept :
|
||||
old(nullptr),
|
||||
mid(0),
|
||||
end(0),
|
||||
capacity(cap),
|
||||
count(0) {
|
||||
|
||||
nex = (int*) malloc(this->capacity * sizeof(uint32_t));
|
||||
}
|
||||
|
||||
inline ~TurboList() noexcept {
|
||||
if(nex) free(nex);
|
||||
if(old) free(old);
|
||||
}
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user