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
package option | |
type Option[T any] struct { | |
value T | |
isFull bool | |
} | |
func Some[T any](value T) Option[T] { | |
return Option[T]{value: value, isFull: true} | |
} |
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 <Arduino.h> | |
#include <WiFi.h> | |
#include <MQTT.h> | |
#include <ArduinoJson.h> | |
char tago_buffer[500]; | |
StaticJsonDocument<500> tago_json; |
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
constexpr size_t operator""_str(const char* str, size_t size) noexcept | |
{ | |
size_t digest = 0; | |
while (size-- > 0) { | |
char val = *str; | |
digest ^= val * val ^ val; // worst hash algorithm | |
++str; | |
} | |
return digest; | |
} |
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 <string> | |
#include <vector> | |
#include <iostream> | |
#include <cctype> | |
#include <memory> | |
// كلاس الأصناف | |
class Product | |
{ | |
public: |
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<iostream> | |
#include<vector> | |
using namespace std; | |
template<typename T, int num> | |
class Stack{ | |
public: | |
void push(const T& t){ |
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<iostream> | |
#include<array> | |
using namespace std; | |
// Stack Container to simplify Stack | |
// operations | |
template<typename T,int SIZE> | |
struct Stack{ |
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<iostream> | |
using namespace std; | |
int QUEUE[100], s_of_element, front, back; | |
void enqueue(void){ | |
int temp; | |
if(back == s_of_element){ | |
cout << "QUEUE IS FULL" << endl; |
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<iostream> | |
using namespace std; | |
int STACK[100], s_of_element, top; | |
void push(void){ | |
int temp; | |
if(top >= s_of_element-1){ | |
cout << "STACK IS FULL" << endl; |
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<iostream> | |
// Improved version of metafunction that convert | |
// Binary to Decimal | |
// | |
template<unsigned long N> | |
struct B_TO_D{ | |
static unsigned constexpr value = B_TO_D<N/10>::value << 1 | N%10; // prepend higher bits to lowest bit | |
}; |