Git Product home page Git Product logo

iterators-in-c's Introduction

Iterators-In-C

The aim of this project is to provide a single interface to iterate over various data-structures in the C language. The following data-structures are currently supported:

  • Arrays
  • Doubly Linked Lists
  • Binary Search Trees

Due to the non generic nature of the C language, the data structures are expected to hold integer values.

How to Compile & Run

Linux & Mac
git clone https://github.com/IamShubhamGupto/Iterators-In-C.git
cd Iterators-In-C
make -f makefile.mk clientfile=<ENTER PATH TO CLIENT FILE NAME HERE>
./bin/a.out

EXAMPLE

make -f makefile.mk clientfile=examples/client1.cpp
./bin/a.out

Clean Up

In order to clean the generated files, run make -f makefile.mk clean.

Data Structures

List

Node Members

Name Definition
value_ stores an integer value.
next_ stores pointer to next node.
prev_ stores pointer to previous node.

List Members

Name Definition
head_ stores pointer to the first node in the list.
tail_ stores pointer to the last node in the list

List Functions

Name Definition
init_list allocate space to list instance.
init_node allocate space and initialize value of list node.
push_front insert node at beginning of the list .
push_back insert node at end of list.
insert insert node at a specificed postion in the list.
pop_back delete node from end of the list.
pop_front delete node from beginning of the list.
erase delete node from a specified postion in the list.
display_list visually display the list.
Tree

Node Members

Name Definition
value_ stores an integer value.
left_ stores pointer to the left child node.
right_ stores pointer to the right child node.
parent_ stores pointer to the parent node.

Tree Members

Name Definition
root_ stores pointer to the root node of the tree

Tree Functions

Name Definition
init_tree allocate space to tree instance.
init_node allocate space and initialize value of tree node.
insert insert node into the tree.
find search for an element in the list
erase delete specified value from a tree
print_tree visually display the tree.
print_in_order helper function utilized by print_tree
is_empty returns 0 or 1 based on if the tree is empty or not
get_leftmost_leaf returns the leftmost child node from the specified node
get_rightmost_leaf returns the rightmost child node from the specified node
in_order_successor returns the in-order-successor from the specified node
in_order_predecessor returns the in-order-predeccessor from the specified node
pre_order_successor returns the pre-order-successor from the specified node

Iterator Functions

Name Definition
init_iterator initialize a concrete iterator class for a type of data structure.
begin return an iterator object pointing to the first element of the data structure.
end return an iterator object pointing to the last element of the data structure.
next increment the iterator by certain postions.
prev decrement the iterator by certain postions.
advance increment/ decrement the iterator by a specified value
distance return the number of elements/distance between given 2 iterators. pre-order distance in-case of a tree.

By

License

This work is licened under GPL v3.0.

iterators-in-c's People

Contributors

iamshubhamgupto avatar shubham2k avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.