Giter VIP home page Giter VIP logo

customvector's Introduction

C++ Custom Vector Template Class

This is an implementation of a template class for storing data in any type. It includes user-friendly interface with lots of helper abstract functions and also custom iterators.

Member Functions

Function Name Parameters Return Type Description
add T element void Adds given element to end of current vector
clear void Clears the vector
count T element int Returns total count of the element
first T Returns first element in the vector
firstIndexOf T element int Returns first index of the element in the vector
getCapacity int Returns capacity of the vector
getSize int Returns size of the vector
insert T element, int index void Inserts given element to a specific index
includes T element bool Returns if the element exists in the vector
isEmpty bool Returns if the vector is empty
last T Returns last element in the vector
lastIndexOf T element int Returns last index of the element in the vector
pop T element Returns first element in the vector and removes it from the vector
push T element void Inserts the element in first index of the vector
select bool (T) CustomVector Returns a sub-vector with elements in the vector which returns true for given lambda function
sort void Sorts the vector
sort bool(T,T) void Sorts the vector according to the given lambda function
subArray int start,int end CustomVector Returns a sub-vector between given indexes
swap int index1, int index2 void Swaps elements in the given indexes
remove T element void Removes all occurances of the element from the vector
removeIf bool(T) void Removes all elements from the vector which return false from given lambda function
removeIndex int index void Removes the element in the given index
removeRange int start, int end void Removes all elements in the given range of indexes
reverse void Reverses order of the vector

Overloaded Operators

Operator Parameters Return Type Description
<< std::ostream stream, CustomVector element std::ostream Inserts elements of the vector to stream via stream insertion operator
+ CustomVector vector,CustomVector other CustomVector Concats elements of two vectors
- CustomVector vector,CustomVector other CustomVector Removes elements of second vector from first vector
^ CustomVector vector,CustomVector other CustomVector Returns an vector which includes intersection of two vectors
== CustomVector vector,CustomVector other bool Returns if two vectors are equal
!= CustomVector vector,CustomVector other bool Returns if two vectors are not equal
[] int index T Returns element in given index
[] {int index1,int index2} CustomVector Returns an sub-vector which includes elements between two indexes

Iterators

This template class comes with its own iterators here and they are all compitable with STL functions such as std::find, std::sort

Function Name Description
begin Returns an iterator which points to start of the vector
end Returns an iterator which points to start of the vector
cbegin Returns an const iterator which points to start of the vector
cend Returns an const iterator which points to start of the vector

Important Note

To use some of listed functions and overloaded operators given T type must support these operations

customvector's People

Stargazers

 avatar  avatar

Watchers

 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.