Found 33676 Articles for Programming

The listIterator() method of AbstractList class in Java

Daniol Thomas
Updated on 30-Jul-2019 22:30:25

127 Views

The listIterator() method of the AbstractList class in Java is used to return a list iterator over the elements in this list.The syntax is as follows.public ListIterator listIterator()Here, ListIterator is an iterator for lists.To work with the AbstractList class, import the following package.import java.util.AbstractList;For ListIterator, import the following package.import java.util.ListIterator;The following is an example to implement listIterator() method of the AbstractlList class in Java.Example Live Demoimport java.util.ArrayList; import java.util.ListIterator; import java.util.AbstractList; public class Demo {    public static void main(String[] args) {       AbstractList myList = new ArrayList();       myList.add(75);       myList.add(100);       ... Read More

The listIterator() method AbstractList class in Java at a specified position

Daniol Thomas
Updated on 30-Jul-2019 22:30:25

112 Views

The listIterator() method of the AbstractList class in Java is used to return a list iterator over the elements in this list, beginning at the specified position in the list.The syntax is as follows.public ListIterator listIterator(int index)Here, index is the index of the first element to be returned from the list iterator, whereas, ListIterator is an iterator for lists.To work with the AbstractList class, import the following package.import java.util.AbstractList;For ListIterator, import the following package.import java.util.ListIterator;The following is an example to implement listIterator() method of the AbstractlList class in Java.Example Live Demoimport java.util.ArrayList; import java.util.ListIterator; import java.util.AbstractList; public class Demo {   ... Read More

C++ Program to Implement Priority_queue in STL

Farhan Muhamed
Updated on 12-May-2025 19:46:02

254 Views

Priority Queue is a special type of queue in which elements can be accessed based on their priority. In this article, we will learn how to use the priority_queue container from the Standard Template Library (STL) in C++. What is Priority Queue? A Priority Queue is a container that stores data in such a way that the highest (or the lowest) priority element will always at the front of queue. Meaning, a priority queue does not follow FIFO rule of a regular queue, it processes elements based on ceratin priority. This priority can be defined as highest elements at ... Read More

ArrayBlockingQueue iterator() method in Java

Daniol Thomas
Updated on 30-Jul-2019 22:30:25

238 Views

The iterator() method of the ArrayBlockingQueue class returns an iterator over the elements in this queue in proper sequence.The syntax is as follows.public Iterator iterator()To work with ArrayBlockingQueue class, you need to import the following package.import java.util.concurrent.ArrayBlockingQueue;The following is an example to implement iterator() method of Java ArrayBlockingQueue class.Example Live Demoimport java.util.ArrayList; import java.util.Iterator; import java.util.concurrent.ArrayBlockingQueue; public class Demo {    public static void main(String[] args) throws InterruptedException {       ArrayBlockingQueue q = new ArrayBlockingQueue(10);       q.add(120);       q.add(10);       q.add(400);       q.add(450);       q.add(500);       q.add(550); ... Read More

C++ Program to Implement Prev_Permutataion in STL

Farhan Muhamed
Updated on 09-May-2025 15:39:04

165 Views

The Prev permutation is an algorithmic operation that rearranges the elements of an array or a range of an array into the previous lexicographically smaller permutation. In this article, we will learn how to use the prev_permutation() function from the Standard Template Library (STL) in C++. What is Prev Permutation? The Prev Permutation is an operation used to generate all the possible permutations of an array in reverse lexicographical order. A permutation is one of the N! arrangements of the elements in an array of size N. The STL library of C++ provide a pre-defined function for performing the ... Read More

Collectors partitioningBy() method in Java 8

Daniol Thomas
Updated on 30-Jul-2019 22:30:25

2K+ Views

The partioningBy() method returns a Collector that partitions the input elements according to a Predicate, and organizes them into a Map.The syntax is as follows.static Collector partitioningBy(Predicate

C++ Program to Implement Pairs in STL

Farhan Muhamed
Updated on 09-May-2025 15:38:46

449 Views

A pair is a container provided by the Standard Template Library (STL) in C++ that stores two heterogeneous objects as a single unit. In this article, we will learn how to use a pair from the Standard Template Library (STL) in C++. What is Pair? Pair is a utility container defined in the header that is used to store two related data elements or objects in pairs. The first element will be referenced as first, and the second element will be referenced as second. It is commonly used to return two values from a function using a single ... Read More

Collectors collectingAndThen() method in Java 8

Daniol Thomas
Updated on 30-Jul-2019 22:30:25

1K+ Views

The collectingAndThen() method in Java Collectors class acclimates a Collector to perform an additional finishing transformation. It returns collector which performs the action of the downstream collector, followed by an additional ending step.The syntax is as follows.static Collector collectingAndThen(Collector downstream, Function finisher)Here, the parameter, T − Type of the input elementsA − Intermediate accumulation type of the downstream collectorR − The result type of the downstream collectorRR − The result type of the resulting collectordownstream − Collectorfinisher − A function to be applied to the final result of the downstream collectorTo work with Collectors class in Java, import the ... Read More

C++ Program to Implement Next_Permutation in STL

Farhan Muhamed
Updated on 09-May-2025 15:38:15

438 Views

Next permutation is an algorithmic operation that rearranges the elements of a range into the next lexicographically greater permutation. In this article, we will learn how to use the next_permutation() function from the Standard Template Library (STL) in C++. What is Next Permutation? The Next Permutation is an operation used to generate all the possible permutations an array in lexicographical order. A permutation is the one of N! arrangements of the elements in an array of size N. If the current sequence is the last permutation, the function transforms it into the first one (i.e., sorted in ascending order). ... Read More

C++ Program to Implement Multiset in STL

Farhan Muhamed
Updated on 07-May-2025 18:29:43

271 Views

A multiset is an associative container that stores data in a sorted order in such a way that it allows duplicate values in the set. In this article, we will learn how to use a multiset from the Standard Template Library (STL) in C++. What is Multiset? Multiset is a sorted associative container that allows storing multiple elements with the same value. The values are automatically arranged in sorted order. This makes it useful in scenarios where you need to keep count of repeated values while maintaining order. For example, we can store the scores of students even ... Read More

Advertisements