Implement Sorting Containers in STL using C++

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:25

180 Views

In this C++ program, we implement Sorting containers in STL.Functions and descriptions:Functions used here:    l.push_back() = It is used to push elements into a list from the front.    l.sort() = Sorts the elements of the list.    Where l is a list object.Example Code#include #include #include #include using namespace std; int main() {    list l;    list::iterator it;    int c, i;    while (1) {       cout

Remove All Method of AbstractSequentialList in Java

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

93 Views

The removeAll() is a method inherited from AbstractCollection class. It removes all the elements of this collection that are also contained in the specified collection.The syntax is as follows:public boolean removeAll(Collection c)Here, the parameter c is the collection having elements to be removed from this collection.To work with the AbstractSequentialList class in Java, you need to import the following package:import java.util.AbstractSequentialList;The following is an example to implement AbstractSequentialList removeAll() method in Java:Example Live Demoimport java.util.LinkedList; import java.util.AbstractSequentialList; public class Demo {      public static void main(String[] args) {       AbstractSequentialList absSequential = new LinkedList();       absSequential.add(210); ... Read More

Launch Another App from Your App

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:25

5K+ Views

This example demonstrates How to launch another app from your appStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     In the above code, we have taken button view to open YouTube application.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.content.ActivityNotFoundException; import android.content.Intent; import android.content.pm.ResolveInfo; import android.content.res.Configuration; import android.graphics.PixelFormat; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.Gravity; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.WindowManager; import ... Read More

1-Persistent CMSA

Rama Giri
Updated on 30-Jul-2019 22:30:25

2K+ Views

1-persistent CSMA is an aggressive version of Carrier Sense Multiple Access (CMSA) protocol that operates in the Medium Access Control (MAC) layer. Using CMSA protocols, more than one users or nodes send and receive data through a shared medium that may be a single cable or optical fiber connecting multiple nodes, or a portion of the wireless spectrum.In 1-persistent CSMA, when a transmitting station has a frame to send and it senses a busy channel, it waits for the end of the transmission, and transmits immediately. Since, it sends with a probability 1, the name 1 – persistent CSMA is ... Read More

Difference Between while(1) and while(0) in C/C++

Nishtha Thakur
Updated on 30-Jul-2019 22:30:25

4K+ Views

Here we will see what are the differences between while(1) and while(0) in C or C++. The while is a loop of C or C++. Using this loop we can check one condition, and the statements inside the loop will be executed while the condition is true.The while(1) or while(any non-zero value) is used for infinite loop. There is no condition for while. As 1 or any non-zero value is present, then the condition is always true. So what are present inside the loop that will be executed forever. To come out from this infinite loop, we have to use ... Read More

8085 Program to Perform Sorting Using Selection Sort

Chandu yadav
Updated on 30-Jul-2019 22:30:25

2K+ Views

Now let us see a program of Intel 8085 Microprocessor. In this program we will see how to sort a sequence of numbers using selection sort.Problem Statement:Write 8085 Assembly language program to sort a given sequence using selection sort in ascending order. The numbers are stored at 8001H onwards. 8000H is holding the block size.Discussion:In the selection sorting technique, we will choose the minimum or the maximum term from a set of numbers. In this case we are considering the sorting in ascending order, so we are choosing the minimum number. By taking the minimum number, we are swapping it ... Read More

Store Array Singleton with Global Context in Android

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

298 Views

Before getting into example, we should know what singleton design pattern is. A singleton is a design pattern that restricts the instantiation of a class to only one instance. Notable uses include controlling concurrency and creating a central point of access for an application to access its data store.This example demonstrate about How to store array Singleton with Global Context in androidStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     In the above ... Read More

Create Quintet Tuple from List in Java

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

93 Views

To create a tuple from List, you need to use fromCollection() method.Let us first see what we need to work with JavaTuples. To work with Quintet class in JavaTuples, you need to import the following package −import org.javatuples.Quintet;Note − Steps to download and run JavaTuples program. If you are using Eclipse IDE to run Quintet Class in JavaTuples, then Right Click Project → Properties → Java Build Path → Add External Jars and upload the downloaded JavaTuples jar file.The following is an example −Exampleimport org.javatuples.Quintet; import java.util.*; public class Demo { public static void main(String[] args) { ... Read More

Escape Literal Syntax Errors in JSP

Samual Sam
Updated on 30-Jul-2019 22:30:25

613 Views

You can escape it using backslash character. Replace

Remove All Common Characters from String Array Elements in Android

Smita Kapse
Updated on 30-Jul-2019 22:30:25

287 Views

This example demonstrate about How to remove all common character from string array elements in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     In the above code, we have taken a text view to show array without common character elements.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.widget.TextView; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; ... Read More

Advertisements