We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Tag: Iterate

How to iterate LinkedList in reverse or backward direction

In this article we will discuss how to iterate over a LinkedList in reverse order. Method 1 : Using Descending Iterator Iterator<E> descendingIterator() Descending Iterator returns the Iterator that points to the end of of List i.e. LinkedList<String> listOfStr = new LinkedList<>(); // Get Descending List Iterator from List Object Iterator<String> listItReverse = listOfStr.descendingIterator(); Now calling function …

How to iterate LinkedList in reverse or backward directionRead More

How to iterate over a LinkedList in Java

In this article we will discuss how to iterate over a LinkedList Collection in Java and access objects. To fetch the Iterator from a LinkedList object use following member function, Advertisements ListIterator<E> listIterator(); It will return ListIterator object that implements Iterator that provides functions to iterate over the LinkedList object. It manages an internal Cursor which is …

How to iterate over a LinkedList in JavaRead More

How to iterate over an unordered_map in C++11

In this article we will discuss the different ways to iterate over an unordered_map. First lets create an unordered_map and then we will see the different ways to iterate over it. // Initialize an unordered_map through initializer_list std::unordered_map<std::string, int> wordMap({{ “First”, 1 },{ “Second”, 2 },{ “Third”, 3 }}); Iterating an unordered_map using range based …

How to iterate over an unordered_map in C++11Read More

How to iterate a map in reverse order – C++

In this article we will discuss how to iterate a map in reverse order. Map store the elements in sorted order of keys. For example, if you store following elements in map i.e. Advertisements {“aaa”, 10}, {“ddd”, 11}, {“bbb”, 12}, {“ccc”, 13} It will internally store the elements in sorted order of keys i.e. {“aaa”, …

How to iterate a map in reverse order – C++Read More

Different ways to iterate over a set in C++

In this article we will discuss different ways to iterate over a set in C++. Let’s create a set of strings i.e. Advertisements // Set of strings std::set<std::string> setOfStr = { “jjj”, “khj”, “bca”, “aaa”, “ddd” }; Now let’s iterate over it and print the contents on screen using different methods i.e. Iterating over a …

Different ways to iterate over a set in C++Read More

C++ : Different Ways to iterate over a List of objects

In this article we will discuss different ways to iterate through std::list of objects. Suppose we have a struct Player that contains id and name i.e. Advertisements struct Player { int id; std::string name; Player(int playerId, std::string playerName) : id(playerId), name(playerName) { } }; Lets create a list Player objects i.e. std::list<Player> listofPlayers = { …

C++ : Different Ways to iterate over a List of objectsRead More

Python : Different ways to Iterate over a List in Reverse Order

In this article we will discuss different ways to Iterate over a python list in reverse order. Suppose we have a python list of strings i.e. Advertisements # List of string wordList = [‘hi’, ‘hello’, ‘this’, ‘that’, ‘is’, ‘of’] Now we want to iterate over this list in reverse order( from end to start ) …

Python : Different ways to Iterate over a List in Reverse OrderRead More

Cart

Your Cart is Empty

Back To Shop