list_array.cpp File Reference

Dynamic Array More...

`#include <iostream>`
`#include <array>`
`#include <cassert>`
Include dependency graph for list_array.cpp:

## Classes

struct | data_structures::list_array::list
| Structure of List with supporting methods. More...

## Namespaces

| data_structures
| Data Structures algorithms.
| list_array
| Functions for Dynamic Array algorithm.

## Functions

static void | test ()
| Test implementations. More...
int | main ()
| Main function. More...

## Detailed Description

Dynamic Array

The list_array is the implementation of list represented using array. We can perform basic CRUD operations as well as other operations like sorting etc.

### Algorithm

It implements various method like insert, sort, search etc. efficiently. You can select the operation and methods will do the rest work for you. You can insert element, sort them in order, search efficiently, delete values and print the list.

## Function Documentation

## main()

int main | ( | void |  | ) |

Main function.

Returns
  0 on exit

{
test(); // Execute the tests
return 0;
}
test
static void test()
Test implementations.
Definition: list_array.cpp:205
Here is the call graph for this function:

## test()

static void test | ( |  | ) |

static

Test implementations.

Returns
  void

{
data_structures::list_array::list L;
// Insert testing
L.insert(11);
L.insert(12);
assert(L.top == 2);
L.insert(15);
L.insert(10);
L.insert(12);
L.insert(20);
L.insert(18);
assert(L.top == 7);
L.show(); // To print the array
// Remove testing
L.remove(12); // Remove Duplicate value in the list
L.remove(15); // Remove the existing value in the list
assert(L.top == 5);
L.remove(50); // Try to remove the non-existing value in the list
assert(L.top == 5);
// LinearSearch testing
assert(L.search(11) == 0); // search for the existing element
assert(L.search(12) == 2);
assert(L.search(50) == -1); // search for the non-existing element
// Sort testing
L.sort();
assert(L.isSorted == true);
L.show();
// BinarySearch testing
assert(L.search(11) == 1); // search for the existing element
assert(L.search(12) == 2);
assert(L.search(50) == -1); // search for the non-existing element
}
data_structures::list_array::list
Structure of List with supporting methods.
Definition: list_array.cpp:32
data_structures::list_array::list::remove
void remove(const uint64_t &val)
To remove the element from the list.
Definition: list_array.cpp:171
data_structures::list_array::list::insert
void insert(const uint64_t &val)
Insert the new element in the list.
Definition: list_array.cpp:132
data_structures::list_array::list::sort
void sort()
Sort the list.
Definition: list_array.cpp:110
data_structures::list_array::list::show
void show()
Utility function to print array.
Definition: list_array.cpp:190
Here is the call graph for this function: