search tree is almost done
This commit is contained in:
@@ -1,3 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "std.h"
|
||||
#include "base_types.h"
|
||||
#include "errors.h"
|
||||
#include "errors.h"
|
||||
|
||||
// just sleeping function
|
||||
// dont set 'milisec' > 1000 for good perfomance
|
||||
void msleep(uint8 sec, uint16 milisec);
|
||||
|
||||
//djb2 hash function from http://www.cse.yorku.ca/~oz/hash.html
|
||||
uint32 hash(char *str);
|
||||
@@ -5,6 +5,10 @@
|
||||
const char* typename(base_type t){
|
||||
switch (t) {
|
||||
case Null: return "Null";
|
||||
case Double: return "Double";
|
||||
case Float: return "Float";
|
||||
case Bool: return "Bool";
|
||||
case Char: return "Char";
|
||||
case Int8: return "Int8";
|
||||
case UInt8: return "UInt8";
|
||||
case Int16: return "Int16";
|
||||
@@ -13,6 +17,14 @@ const char* typename(base_type t){
|
||||
case UInt32: return "UInt32";
|
||||
case Int64: return "Int64";
|
||||
case UInt64: return "UInt64";
|
||||
case Int8Ptr: return "Int8Ptr";
|
||||
case UInt8Ptr: return "UInt8Ptr";
|
||||
case Int16Ptr: return "Int16Ptr";
|
||||
case UInt16Ptr: return "UInt16Ptr";
|
||||
case Int32Ptr: return "Int32Ptr";
|
||||
case UInt32Ptr: return "UInt32Ptr";
|
||||
case Int64Ptr: return "Int64Ptr";
|
||||
case UInt64Ptr: return "UInt64Ptr";
|
||||
default: throw(ERR_WRONGTYPE); return "EEEEEE";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,9 @@ typedef uint32_t uint32;
|
||||
typedef int64_t int64;
|
||||
typedef uint64_t uint64;
|
||||
typedef enum base_type{
|
||||
Null, Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64, Char, Bool
|
||||
Null, Float, Double, Char, Bool,
|
||||
UInt8, Int8, UInt16, Int16, UInt32, Int32, UInt64, Int64,
|
||||
UInt8Ptr, Int8Ptr, UInt16Ptr, Int16Ptr, UInt32Ptr, Int32Ptr, UInt64Ptr, Int64Ptr
|
||||
} __attribute__ ((__packed__)) base_type;
|
||||
|
||||
const char* typename(base_type t);
|
||||
|
||||
@@ -14,7 +14,3 @@ void _throwstr(const char* errmesg, const char* srcfile, int line, const char* f
|
||||
CHOOSE(IFTYPE(E,int), _throwint(E,__FILE__,__LINE__,__func__), \
|
||||
CHOOSE(IFTYPE(E,char[]), _throwstr(E,__FILE__,__LINE__,__func__), \
|
||||
printf("\e[31m[%s:%d/%s] UNKNOWN ERROR\n",__FILE__,__LINE__,__func__)))
|
||||
|
||||
#define ifNthrow(PTR) if (!PTR) throw(ERR_NULLPTR)
|
||||
#define ifNretN(PTR) if (!PTR) return NULL
|
||||
#define ifNret(PTR) if (!PTR) return
|
||||
9
DtsodC/src/base/hash.c
Normal file
9
DtsodC/src/base/hash.c
Normal file
@@ -0,0 +1,9 @@
|
||||
#include "base.h"
|
||||
|
||||
uint32 hash(char *str){
|
||||
uint32 hash=5381;
|
||||
char c;
|
||||
while (c=*str++)
|
||||
hash=((hash << 5) + hash) + c; //hash=hash*33^c
|
||||
return hash;
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "std.h"
|
||||
#include "base_types.h"
|
||||
#include "base.h"
|
||||
|
||||
void nsleep(uint8 sec, uint8 milisec){
|
||||
void msleep(uint8 sec, uint16 milisec){
|
||||
if (sec>0)
|
||||
sleep(sec);
|
||||
if (milisec>0)
|
||||
Reference in New Issue
Block a user