We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Tag: Elements

How to add elements at a particular index in LinkedList

In this article we will discuss how to add elements at a particular index or position in a LinkedList in Java. add() member function of LinkedList always appends the element at the end of LinkedList. Now suppose we don’t want to add element at the end of Linked List instead of it we want to add element somewhere …

How to add elements at a particular index in LinkedListRead More

How to add elements in a LinkedList in Java

In this article we will discuss how to add elements in LinkedList and then display them. Lets create a LinkedList of String i.e. Advertisements List<String> listOfStr = new LinkedList<>(); To add elements in LinkedList we will use its add() function i.e. boolean add(E e) add() member function of LinkedList always appends the element in the …

How to add elements in a LinkedList in JavaRead More

How to erase elements from a list in c++ using iterators

In this article we will see how to erase elements from a std::list using iterators. std::list provides 2 member function to delete elements using iterators i.e. Advertisements iterator erase (const_iterator position); It deletes the element representing by passed iterator “position” and returns the iterator of element next to last deleted element. iterator erase (const_iterator first, const_iterator last); …

How to erase elements from a list in c++ using iteratorsRead More

How to remove elements from a List based on value or External Criterion

In this article we will discuss how to remove an element from a List by matching a value or by matching some criterion. std::list provides two member functions for removing elements based on value i.e. std::list::remove and std::list::remove_if. Advertisements Using std::list::remove to remove element by value void remove (const value_type& val); It removes all the elements …

How to remove elements from a List based on value or External CriterionRead More

How to Insert elements in an unordered_set in C++11

std::unordered_set provides the different overloaded versions of insert() member function to insert elements i.e. pair<iterator,bool> insert ( const value_type& val ); void insert ( InputIterator first, InputIterator last ); void insert ( initializer_list<value_type> il ); Let’s see each of them in detail Advertisements Inserting element in unordered_set by value For this we will use basic …

How to Insert elements in an unordered_set in C++11Read More

Different ways to insert elements in an unordered_map

In this article we will discuss the different ways to insert elements in an unordered_map. Unordered_map provides different overloaded versions of insert() member function to insert key value pairs in an unordered_map. Lets discuss them one by one. Advertisements Inserting multiple elements in unordered_map through an initializer_list unordered_map provides an overloaded version of insert that …

Different ways to insert elements in an unordered_mapRead More

c++11 unordered_map : erase elements while iterating in a loop

In this article we will discuss how to erase multiple elements from an unordered_map based on some condition and while iterating. Erasing Multiple elements from unordered_map while iterating Suppose we have an unordered_map of string and integers as key value pairs i.e. Advertisements First : 1 Second : 2 Third : 3 Fourth :  4 Fifth : 5 …

c++11 unordered_map : erase elements while iterating in a loopRead More

Cart

Your Cart is Empty

Back To Shop