Found 34475 Articles for Programming

C++ Program to Implement Multimap in STL

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:25

317 Views

Multimap is similar to map with an exception that multiple elements can have same keys. The key value and mapped value pair has to be unique in multimap.Function is used here -mm::find() – Returns an iterator to the element with key value ‘b’ in the multimap if found, else returns the iterator to end.mm::erase() – Removes the key value from the multimap.mm:: equal_range() – Returns an iterator of pairs. The pair refers to the bounds of a range that includes all the elements in the container which have a key equivalent to key.mm insert() – To insert elements in the ... Read More

IntStream mapToObj() method in Java

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

2K+ Views

The mapToObj() method in the IntStream class returns an object-valued Stream consisting of the results of applying the given function to the elements of this stream.The syntax is as follows. StreammapToObj(IntFunction

LongStream iterator() method in Java

Nancy Den
Updated on 30-Jul-2019 22:30:25

102 Views

The iterator() method of the LongStream class in Java returns an iterator for the elements of this stream.The syntax is as follows.PrimitiveIterator.OfLong iterator()Here, PrimitiveIterator is an Iterator specialized for long values.To use the LongStream class in Java, import the following package.import java.util.stream.LongStream;The following is an example to implement LongStream iterator() method in Java.Example Live Demoimport java.util.*; import java.util.stream.LongStream; public class Demo {    public static void main(String[] args) {       LongStream longStream = LongStream.of(15000L, 17000L, 25000L);       PrimitiveIterator.OfLong i = longStream.iterator();       while (i.hasNext()) {          System.out.println(i.nextLong());       }   ... Read More

C++ Program to Implement Map in STL

Nitya Raut
Updated on 30-Jul-2019 22:30:25

3K+ Views

A Map is an associative container that store elements in a mapped fashion. Each element has a key value and a mapped value. No two mapped values can have same key values.Functions are used here:m::find() – Returns an iterator to the element with key value ‘b’ in the map if found, else returns the iterator to end.m::erase() – Removes the key value from the map.m:: equal_range() – Returns an iterator of pairs. The pair refers to the bounds of a range that includes all the elements in the container which have a key equivalent to key.m insert() – To insert ... Read More

Create Octet Tuple using with() method in Java

Nancy Den
Updated on 30-Jul-2019 22:30:25

61 Views

You can easily create Octet Tuple in Java using with() method. Let us first see what we need to work with JavaTuples. To work with Octet class in JavaTuples, you need to import the following package.import org.javatuples.Octet;Note: Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then Right Click Project → Properties → Java Build Path → Add External Jars and upload the downloaded JavaTuples jar file. Refer the below guide for all the steps to run JavaTuples.Steps: How to run JavaTuples program in EclipseThe following is an example to create Octet Tuple using with() ... Read More

C++ Program to Implement List in STL

Nitya Raut
Updated on 30-Jul-2019 22:30:25

247 Views

A list is a sequence container that allow non-contiguous memory allocation. List has slow traversal as compared to vector, but once a position has been found, insertion and deletion are quick.Functions and descriptions:From main(), we have called following functions:    fl.resize() = Returns the resize of list.    fl.push_front() = It is used to push elements into a list from the front.    fl.remove() = Deletes elements from list.    fl.unique() = Deletes duplicate elements from list.    fl.reverse() = Reverses the list.    fl.front() = Returns the front element of list.Example Code#include #include #include #include using ... Read More

How to create Octet Tuple in Java?

Nancy Den
Updated on 30-Jul-2019 22:30:25

85 Views

An Octetclass is a Tuple of 8 element. It is in the JavaTuples library. Let us first see what we need to work with JavaTuples. To work with Octet class in JavaTuples, you need to import the following package.import org.javatuples.Octet;Note: Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then Right Click Project -> Properties -> Java Build Path -> Add External Jars and upload the downloaded JavaTuples jar file. Refer the below guide for all the steps to run JavaTuples.Steps: How to run JavaTuples program in EclipseThe following is an example to create Octet ... Read More

What is AbstractCollection class in Java?

Nancy Den
Updated on 30-Jul-2019 22:30:25

377 Views

The AbstractCollection class provides an implementation of the Collection interface. This is done to minimize the effort in the implementation of this interface.For an unmodifiable collectionExtend this class and provide implementations for the iterator and size methods.For modifiable collectionAdditionally override the add() method of the class. The iterator method returns the iterator and it must implement the remove() method.The syntax is as follows.public abstract class AbstractCollection extends Object implements CollectionHere, Object is the root of the class hierarchy and Collection is a group of objects.To work with AbstractCollection class in Java, import the following package.import java.util.AbstractCollection;Let us now see an ... Read More

StringJoiner setEmptyValue() method in Java 8

Nancy Den
Updated on 30-Jul-2019 22:30:25

273 Views

The setEmptyValue() method of the StringJoiner class in Java 8 sets the sequence of characters. These characters are to be used when determining the string representation of this StringJoiner and when it is empty. That would be none of the elements have been added.The syntax is as followspublic StringJoiner setEmptyValue(CharSequence emptyVal)Here, emptyVal are the characters to return as the value of an empty StringJoinerTo work with the StringJoiner in Java 8, import the following package.import java.util.StringJoiner;The following is an example to implement StringJoiner setEmptyValue() method in Java:Example Live Demoimport java.util.StringJoiner; public class Demo {    public static void main(String[] args) { ... Read More

C++ Program to Implement Forward_List in STL

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:25

171 Views

Forward list in STL implements singly linked list. List is different by forward_list that list keeps track to both next and previous elements.While forward list keeps track of location of only next elements, thus increasing the storage space required to store each element. The disadvantage of forward_list is that is individual elements cannot be accessed directly and it cannot be iterated backwards.Functions and descriptions:From main(), we have called following functions:    fl.resize() = Returns the resize of forward_list.    fl.push_front() = It is used to push elements into a foward_list from the front.    fl.remove() = Deletes elements from forward_list. ... Read More

Advertisements