This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool pop(T& obj) { | |
for (;;) { | |
const i32 pos = rd; | |
Item* j = &objects[pos % CAPACITY]; | |
const i32 seq = j->seq; | |
if (seq < pos + 1) { | |
// nothing to pop | |
return false; | |
} | |
else if (seq == pos + 1) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <urlmon.h> | |
#pragma comment(lib, "urlmon.lib") | |
bool download(const char* url, OutputMemoryStream& blob) { | |
IStream* stream = nullptr; | |
if (S_OK != URLOpenBlockingStream(nullptr, url, &stream, 0, nullptr)) { | |
return false; | |
} | |
char buffer[4096]; | |
ULONG read = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// only handles coplexity on top level, if you have a node with 1M children, you are out of luck | |
// changes in clipped parts are not detected, so if somebody deleted nodes in clipped, scrollbar is not updated until user actually scrolls | |
// scrolling and changes refresh the clipper == that part is as slow as no clipping at all | |
// only single list in BeginChild/EndChild is tested | |
struct TreeViewClipper { | |
// persist | |
float cursor_end = 0; | |
float cursor_visible_start = 0; | |
uint first_visible_index = 0; | |
float last_scroll = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void radixSort2(u64* _keys, u64* _values, int size) { | |
enum { WORKERS = 10 }; | |
PROFILE_FUNCTION(); | |
profiler::pushInt("count", size); | |
if (size == 0) return; | |
Array<u64>& tmp_mem = allocRadixTmp(); | |
u64* keys = _keys; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading; | |
using System.Runtime.InteropServices; | |
using System.Runtime.InteropServices.ComTypes; | |
using System.Text.RegularExpressions; | |
using System.Diagnostics; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename F> | |
static void measure(float& avg, float& med, float& min, float& max, F&& func) { | |
LARGE_INTEGER b, e, f; | |
enum { ITERS = 10 }; | |
LONGLONG dur[ITERS]; | |
LONGLONG sum = 0; | |
for (int i = 0; i < 5; ++i) { | |
func(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
template <typename T> | |
class Nullable | |
{ | |
public: | |
Nullable(T* _val) : value(_val) {} | |
void operator=(const Nullable<T>& rhs) { value = rhs.value; } |