This file contains hidden or 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
/* | |
Basic implementation of an event bus in dart. | |
any function anywhere in code can subscribe themselves to specific methods in the event bus. such as: | |
EventBus.subscribe(eventBusFn, callbackFn) | |
to call an event bus function, and call any subscribing functions as well, run: | |
EventBus.call(eventBusFn, args) |
This file contains hidden or 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
// Demonstrating a Tensor class. This tensor holds vector3's as | |
// keys and doubles as values. It has the benefit of ordering the | |
// vector3's and counting duplicates in the value slot. | |
// Easy addition to the values. | |
// | |
// My use case is storing voxelized information about a phantom | |
// in a medical physics application and recording total energy | |
// deposited in each position voxel. | |
// pos_energy_tensor |
This file contains hidden or 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
/* | |
README | |
Simple cache program in C. | |
The goal here was to create a cache for the 'do_thing' function. | |
Theoretically do_thing would take a lot of computation and the | |
use of a cache would speed it up. So if a user puts in the same | |
value twice e.g. do_thing(2.0), do_thing(2.0) the second call | |
will extract the already calculated value from the cache instead | |
of calculating it again. |
This file contains hidden or 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
// testing how many threads work in c++ | |
// spoiler alert: at least 2000 work, probably more | |
#include <thread> | |
#include <iostream> | |
#include <chrono> | |
#include <vector> | |
void count(int threadNumber){ | |
// Function that counts 5 seconds |
This file contains hidden or 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
// showing how copying an instance of a class | |
// doesn't copy the dynamically allocated variables, | |
// it simply copies over their address. So the new | |
// copy shares the old variable. | |
#include <iostream> | |
class Thing{ | |
public: | |
Thing(){ pInt = new int; } |
This file contains hidden or 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
// explanation: | |
// Defines 3 classes: Parent, Child, and Thing. | |
// Thing takes in a parent into its constructor. | |
// Parent initializes a Thing in its constructor using 'this.' | |
// Child does nothing but initialize Parent(). | |
// | |
// main initializes a Child class, and calls a function from Thing. | |
// Thing, which was initialized using 'this' in the parent constructor, | |
// uses that 'this' to refer to the Child, not the Parent. |
This file contains hidden or 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 <iostream> | |
#include <string> | |
#include <map> | |
#include <vector> | |
int main() | |
{ | |
// a map is a really good way to keep track of information. | |
// if the key doesn't exist, it will be created. | |
// if the key does exist, it will just reassign the value |