# Algorithms_in_C++: data_structures/cll/cll.h Source File

cll.h
/*
* Simple data structure CLL (Cicular Linear Linked List)
* */
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <iostream>
#ifndef CLL_H
#define CLL_H
/*The data structure is a linear linked list of integers */
struct node {
int data;
node* next;
};
class cll {
public:
cll(); /* Construct without parameter */
~cll();
void display(); /* Show the list */
/******************************************************
* Useful method for list
*******************************************************/
void insert_front(int new_data); /* Insert a new value at head */
void insert_tail(int new_data); /* Insert a new value at tail */
int get_size(); /* Get total element in list */
bool find_item(int item_to_find); /* Find an item in list */
/******************************************************
* Overloading method for list
*******************************************************/
int operator*(); /* Returns the info contained in head */
/* Overload the pre-increment operator.
The iterator is advanced to the next node. */
void operator++();
protected:
node* head;
int total; /* Total element in a list */
};
#endif
mov
void mov(tower *From, tower *To)
Definition: tower_of_hanoi.cpp:39
main
int main()
Definition: caesar_cipher.cpp:120
std::srand
T srand(T... args)
ciphers::HillCipher::get_idx_char
static char get_idx_char(const uint8_t idx)
Get the character at a given index in the STRKEY.
Definition: hill_cipher.cpp:182
ciphers::caesar::encrypt
std::string encrypt(const std::string &text, const int &shift)
Definition: caesar_cipher.cpp:65
ciphers::HillCipher::codec
static const std::string codec(const std::string &text, const matrix< int > &key)
Convenience function to perform block cipher operations. The operations are identical for both encryp...
Definition: hill_cipher.cpp:210
std::strlen
T strlen(T... args)
std::string
STL class.
main
int main()
Definition: vigenere_cipher.cpp:131
main
int main()
Definition: sudoku_solve.cpp:131
ciphers::HillCipher::generate_encryption_key
static matrix< int > generate_encryption_key(size_t size, int limit1=0, int limit2=10)
Generate encryption matrix of a given size. Larger size matrices are difficult to generate but provid...
Definition: hill_cipher.cpp:339
std::pair
ciphers::HillCipher
Implementation of Hill Cipher algorithm.
Definition: hill_cipher.cpp:81
main
int main()
Definition: n_queens.cpp:118
std::vector
STL class.
deleteNode
node * deleteNode(node *root, int key)
Definition: avltree.cpp:88
std::array::size
T size(T... args)
MinHeap::deleteKey
void deleteKey(int i)
Definition: binaryheap.cpp:105
backtracking
Backtracking algorithms.
Definition: graph_coloring.cpp:26
MinHeap
Definition: binaryheap.cpp:10
main
int main()
Definition: minimax.cpp:54
MinHeap::heap_size
int heap_size
Current number of elements in min heap.
Definition: binaryheap.cpp:13
node
Definition: avltree.cpp:13
node
struct list node
test2
void test2(const std::string &text)
Self test 2 - using 8x8 randomly generated key.
Definition: hill_cipher.cpp:505
std::setfill
T setfill(T... args)
MinHeap::decreaseKey
void decreaseKey(int i, int new_val)
Definition: binaryheap.cpp:76
levelOrder
void levelOrder(node *root)
Definition: avltree.cpp:119
std::queue
STL class.
backtracking::isPossible
bool isPossible(const std::array< std::array< int, V >, V > &mat, int i, int j, int no, int n)
Definition: sudoku_solve.cpp:36
ciphers
Algorithms for encryption and decryption.
test
void test()
Definition: xor_cipher.cpp:75
caesar
Functions for Caesar cipher algorithm.
main
int main()
Definition: xor_cipher.cpp:95
ciphers::STRKEY
static const char * STRKEY
Definition: hill_cipher.cpp:73
vigenere
Functions for vigenère cipher algorithm.
ciphers::HillCipher::gcd
static const T gcd(T a, T b)
Compute GCD of two integers using Euler's algorithm.
Definition: hill_cipher.cpp:138
MinHeap::insertKey
void insertKey(int k)
Definition: binaryheap.cpp:55
createNode
node * createNode(int data)
Definition: avltree.cpp:21
main
int main()
Definition: hill_cipher.cpp:532
std::isfinite
T isfinite(T... args)
n_queens
Functions for Eight Queens puzzle.
cll
Definition: cll.h:17
MinHeap::capacity
int capacity
maximum possible size of min heap
Definition: binaryheap.cpp:12
insert
node * insert(node *root, int item)
Definition: avltree.cpp:66
ciphers::HillCipher::get_inverse
static matrix< double > get_inverse(matrix< T > const &A)
Definition: hill_cipher.cpp:250
backtracking::printMat
void printMat(const std::array< std::array< int, V >, V > &mat, int n)
Definition: sudoku_solve.cpp:66
ciphers::HillCipher::generate_decryption_key
static matrix< int > generate_decryption_key(matrix< int > const &encrypt_key)
Generate decryption matrix from an encryption matrix key.
Definition: hill_cipher.cpp:371
std::cout
h
int h(int key)
Definition: hash_search.cpp:45
std::ofstream
STL class.
MinHeap::harr
int * harr
pointer to array of elements in heap
Definition: binaryheap.cpp:11
std::string::compare
T compare(T... args)
ciphers::HillCipher::encrypt_text
static const std::string encrypt_text(const std::string &text, const matrix< int > &encrypt_key)
Encrypt a given text using a given key.
Definition: hill_cipher.cpp:445
std::array
STL class.
ciphers::HillCipher::decrypt_text
static const std::string decrypt_text(const std::string &text, const matrix< int > &decrypt_key)
Decrypt a given text using a given key.
Definition: hill_cipher.cpp:457
std::ofstream::close
T close(T... args)
MinHeap::MinHeapify
void MinHeapify(int)
Definition: binaryheap.cpp:113
std::valarray
STL class.
height
int height(node *root)
Definition: avltree.cpp:31
XOR
Functions for XOR cipher algorithm.
test
void test()
Definition: vigenere_cipher.cpp:111
rightRotate
node * rightRotate(node *root)
Definition: avltree.cpp:41
ciphers::HillCipher::get_char_idx
static uint8_t get_char_idx(const char ch)
Get the index of a character in the STRKEY.
Definition: hill_cipher.cpp:190
endl
#define endl
Definition: matrix_exponentiation.cpp:36
backtracking::isSafe
bool isSafe(int v, const std::array< std::array< int, V >, V > &graph, const std::array< int, V > &color, int c)
Definition: graph_coloring.cpp:51
MinHeap::left
int left(int i)
Definition: binaryheap.cpp:31
std::rand
T rand(T... args)
std::swap
T swap(T... args)
std::min
T min(T... args)
test1
void test1(const std::string &text)
Self test 1 - using 3x3 randomly generated key.
Definition: hill_cipher.cpp:470
ciphers::HillCipher::generate_keys
static std::pair< matrix< int >, matrix< int > > generate_keys(size_t size, int limit1=0, int limit2=10)
Generate encryption and decryption key pair.
Definition: hill_cipher.cpp:424
backtracking::minimax
int minimax(int depth, int node_index, bool is_max, const std::array< int, T > &scores, double height)
Definition: minimax.cpp:38
backtracking::n_queens::solveNQ
void solveNQ(std::array< std::array< int, n >, n > board, const int &col)
Definition: n_queens.cpp:90
main
int main()
Definition: knight_tour.cpp:80
ciphers::caesar::decrypt
std::string decrypt(const std::string &text, const int &shift)
Definition: caesar_cipher.cpp:81
data
int data[MAX]
test data
Definition: hash_search.cpp:24
minValue
node * minValue(node *root)
Definition: avltree.cpp:59
ciphers::HillCipher::rand_range
static double rand_range(matrix< T2 > *M, T1 a, T1 b)
Function overload to fill a matrix with random integers in a given interval.
Definition: hill_cipher.cpp:118
std::round
T round(T... args)
queue::front
Kind front()
Definition: queue.h:61
queue
Definition: queue.h:17
std::endl
T endl(T... args)
backtracking::printSolution
void printSolution(const std::array< int, V > &color)
Definition: graph_coloring.cpp:32
std::left
T left(T... args)
MinHeap::MinHeap
MinHeap(int cap)
Definition: binaryheap.cpp:19
backtracking::graphColoring
void graphColoring(const std::array< std::array< int, V >, V > &graph, int m, std::array< int, V > color, int v)
Definition: graph_coloring.cpp:69
backtracking::issafe
bool issafe(int x, int y, const std::array< std::array< int, V >, V > &sol)
Definition: knight_tour.cpp:33
std
STL namespace.
main
int main()
Definition: avltree.cpp:134
determinant_lu
double determinant_lu(const matrix< T > &A)
Definition: lu_decomposition.h:90
graph
Graph algorithms.
ciphers::HillCipher::rand_range
static const T2 rand_range(T1 a, T1 b)
Function to generate a random integer in a given interval.
Definition: hill_cipher.cpp:92
operator<<
static std::ostream & operator<<(std::ostream &out, matrix< T > const &v)
Definition: hill_cipher.cpp:54
backtracking::solveSudoku
bool solveSudoku(std::array< std::array< int, V >, V > &mat, int i, int j)
Definition: sudoku_solve.cpp:91
std::make_pair
T make_pair(T... args)
std::time
T time(T... args)
std::setw
T setw(T... args)
std::max
T max(T... args)
leftRotate
node * leftRotate(node *root)
Definition: avltree.cpp:50
std::cin
ciphers::HillCipher::mat_mul
static const std::valarray< uint8_t > mat_mul(const std::valarray< uint8_t > &vector, const matrix< int > &key)
helper function to perform vector multiplication with encryption or decryption matrix
Definition: hill_cipher.cpp:159
MinHeap::getMin
int getMin()
Definition: binaryheap.cpp:43
std::vector::data
T data(T... args)
test
void test()
Definition: caesar_cipher.cpp:100
std::exit
T exit(T... args)
getBalance
int getBalance(node *root)
Definition: avltree.cpp:38
main
int main()
Definition: graph_coloring.cpp:96
Queue
Definition: binary_search_tree.cpp:17
MinHeap::extractMin
int extractMin()
Definition: binaryheap.cpp:85
MinHeap::right
int right(int i)
Definition: binaryheap.cpp:34
backtracking::solve
bool solve(int x, int y, int mov, std::array< std::array< int, V >, V > &sol, const std::array< int, V > &xmov, std::array< int, V > &ymov)
Definition: knight_tour.cpp:50