Skip to content

Instantly share code, notes, and snippets.

View EgoPingvina's full-sized avatar
🦖
Working from home

Aleksei Biriukov EgoPingvina

🦖
Working from home
View GitHub Profile
@EgoPingvina
EgoPingvina / TruncateByTraverseBF.cs
Created July 31, 2020 09:55
c# truncate the tree, keeping the specified number of nodes
public Node TruncateByTraverseBF(Node root,int count)
{
if (count <= 0)
return null;
if (count == 1)
{
root.Children.Clear();
return root;
}
@EgoPingvina
EgoPingvina / Singleton.hpp
Last active June 22, 2020 09:26
Implementation of a generic singleton template on C++. It allows turning any class to singleton by one line.
#pragma once
/// <summary>
/// The singleton`s implementation to Insert into any other class.
/// </summary>
/// <typeparam name="T">The class which will be turned into Singleton.</typeparam>
/// <param name="Action">Actions to be taken in the default constructor.</typeparam>
#define Singleton(T, Action) \
protected: \
T() { (Action)(); } \