A

@abhaumik

Observer design pattern

C++
1 year ago
#include <iostream> #include <list> using namespace std; class Iobserver { public: virtual void notify(string msg) = 0; };

builder design pattern in aggregation type

C++
1 year ago
#include <iostream> using namespace std; // Build the product desktop class Desktop { public: string monitor; string keyboard;

Builder design pattern in associative way

C++
1 year ago
#include <iostream> using namespace std; // Build the product desktop class Desktop { public: string monitor; string keyboard;

abstract factory pattern

C++
1 year ago
#include <iostream> using namespace std; class car { public: virtual void showcar()=0; };

trie implementation

C++
1 year ago
#include <iostream> using namespace std; class Trienode{ vector<Trienode*>child; int count; public: Trienode() {

Singleton design pattern using thread safe

C++
1 year ago
#include <iostream> #include <thread> #include <mutex> using namespace std; class singleton { private: static int count; static singleton *instance; // this instace is created as static as it will crete only once and all the objects

Factory Design Pattern

C++
1 year ago
#include <iostream> using namespace std; class vehicle { public: virtual void showvehicle()=0;

shallow copy and deep copy

C++
1 year ago
#include <iostream> using namespace std; class Temp { private: int *x; public: Temp(int m) //PARAMETERIZED CONSTRUCTOR

friend class

C++
1 year ago
#include <iostream> using namespace std; class Base { private: int x; protected:

producer consumer problem

C++
1 year ago
#include <iostream> #include <mutex> #include <thread> #include<condition_variable> #include<deque> using namespace std; std::mutex m1; std::condition_variable cv; deque<int>buffer; const unsigned int maxbuffersize=100;

condition variable

C++
1 year ago
#include <iostream> #include <thread> #include <mutex> #include <condition_variable> using namespace std; mutex m; condition_variable cv; int balance=0; void deposit_money(int money)

timed mutex

C++
1 year ago
#include <iostream> #include <mutex> #include <thread> #include <chrono> using namespace std; mutex m; int value=0; void function(int c) {

trylock multiple mutex

C++
1 year ago
#include <iostream> #include <thread> #include <mutex> using namespace std; mutex m1,m2; int x=0,y=0; void consume_xy() { while(1)

mutex lock, mutex try lock

C++
1 year ago
#include <iostream> #include <thread> using namespace std; #include<mutex> std::mutex m1; int count =0; /* void func() // lock {

Finding the max element except the given ith element in an array

C++
1 year ago
#include <iostream> #include<vector> #include<math.h> using namespace std; void max_ele_apart_from_ith(vector<int>arr,vector<int>query,int n,int m) { vector<int>prefixsum(n,0); vector<int>suffixsum(n,0);

Socket programming server side

C++
1 year ago
#include <iostream> #pragma comment(lib,"ws2_32.lib"); //library for the socket using namespace std; #incluse<tchar.h> //Socket Programming /* Server side -Initialize the socket -create the socket

Shared Pointer (another type smart pointer)

C++
1 year ago
#include <iostream> using namespace std; template<typename T> class sharedptr{ private: T *res; T *counter;

Unique pointer

C++
1 year ago
#include <iostream> using namespace std; template<typename T> // because of using the template we can actually use any data type of your choice so this is generic class uniqueptr{ private: T *res; // it will have the same size as of the raw poin

Smart Pointers (RAII)

C++
1 year ago
#include <iostream> using namespace std; class smartptr { private: int *ptr; public: smartptr(int *val=nullptr) : ptr(val){

private and protected

C++
1 year ago
#include <iostream> using namespace std; class Base { private: int baseval1; protected: int baseval2;