Output Iterators in C++ Programming

Ayush Gupta
Updated on 14-Apr-2020 12:09:22

160 Views

In this tutorial, we will be discussing a program to understand output iterators in C++.Output iterators are a part of the major five iterators. They function opposite of the input iterators in a way that they can be assigned values but can’t be accessed to fetch values.Example Live Demo#include #include using namespace std; int main(){    vectorv1 = {1, 2, 3, 4, 5};    //declaring iterator    vector::iterator i1;    for (i1=v1.begin();i1!=v1.end();++i1){       *i1 = 1;    }    return 0; }OutputNo output, because we cannot access values of output operators

Ordered Set and GNU C++ PBDS

Ayush Gupta
Updated on 14-Apr-2020 12:07:48

2K+ Views

In this tutorial, we will be discussing a program to understand ordered set and GNU C++ PBDS.Ordered set is a policy based structure other than those in the STL library. The ordered set keeps all the elements in a sorted order and doesn’t allow duplicate values.Example Live Demo#include using namespace std; #include #include using namespace __gnu_pbds; #define ordered_set tree int main(){    //declaring ordered set    ordered_set o_set;    o_set.insert(5);    o_set.insert(1);    o_set.insert(2);    cout

Order of Constructor and Destructor Call in C++

Ayush Gupta
Updated on 14-Apr-2020 12:04:57

542 Views

In this tutorial, we will be discussing a program to understand the order of constructor/ destructor in C++.Order of constructor/destructor refers to the pattern in which the constructors of various classes are called during inheritance of classes.Example Live Demo#include using namespace std; //parent class class Parent{    public:    Parent(){       cout

Operator Overloading in C++ to Print Contents of Vector and Map Pair

Ayush Gupta
Updated on 14-Apr-2020 12:02:26

616 Views

In this tutorial, we will be discussing a program to understand operator overloading in C++ to print contents of vector, map and pair.Operator overloading is the function of operators which gives them the ability to act on User defined objects and work accordingly in a similar fashion.ExampleVector Live Demo#include #include using namespace std; template ostream& operator

Merge Operations Using STL in C++

Ayush Gupta
Updated on 14-Apr-2020 11:58:44

155 Views

In this tutorial, we will be discussing a program to understand the various merge operations using STL in C++.The merge() function is used to merge two sorted containers in a way that the new container is also sorted. Further includes() is used to check if the elements from first container are present in the second one.Example Live Demo#include #include #include using namespace std; int main(){    vector v1 = {1, 3, 4, 5, 20, 30};    vector v2 = {1, 5, 6, 7, 25, 30};    //initializing resultant vector    vector v3(12);    merge(v1.begin(), v1.end(), v2.begin(),    v2.end(), v3.begin());    cout

Coupling in C#

George John
Updated on 14-Apr-2020 11:09:33

3K+ Views

Coupling shows the relationship between modules in C# or you can say the interdependence between modules.There are two types of coupling i.e tight and loose coupling.Loose CouplingLoose coupling is preferred since through it changing one class will not affect another class. It reduces dependencies on a class. That would mean you can easily reuse it.Writing loosely coupled code has the following advantages −One module won’t break other modulesEnhances testabilityCode is easier to maintainGets less affected by changes in other components.Tight CouplingIn Tight Coupling, the classes and objects are dependent on each other and therefore reduce re-usability of code.Read More

Implement Flow API Using Publisher Subscriber in Java 9

raja
Updated on 14-Apr-2020 10:31:19

2K+ Views

Flow API (java.util.concurrent.Flow) has introduced in Java 9. It helps to understand different ways in which the Publisher and Subscriber interfaces interact to perform desired operations.Flow API consists of Publisher, Subscriber, Subscription, and Processor interfaces, which can be based on reactive stream specification.In the below example, we can implement Flow API by using Publisher-Subscriber interfaces.Exampleimport java.util.concurrent.Flow.Publisher; import java.util.concurrent.Flow.Subscriber; import java.util.concurrent.Flow.Subscription; public class FlowAPITest {    public static void main(String args[]) {       Publisher publisherSync = new Publisher() {   // Create publisher          @Override          public void subscribe(Subscriber

What is Text Origin in JavaFX

Maruthi Krishna
Updated on 14-Apr-2020 08:53:51

376 Views

In addition to the local coordinate system for positioning its nodes, JavaFX provides an additional coordinate system for the text node.The textOrigin property specifies the origin of the coordinates of the text node in the parent coordinate system. You can set values to this property using the setTextOrigin() method. This method accepts one of the constants of the enum named VPos. This enum contains 4 constants namely: BASELINE, BOTTOM, CENTER and, TOP.Exampleimport java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.InputStream; import java.util.Scanner; import javafx.application.Application; import javafx.geometry.VPos; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.paint.Color; import javafx.stage.Stage; import javafx.scene.text.Text; public class TextOriginExample extends Application {   ... Read More

Strike Through and Underline Text in JavaFX

Maruthi Krishna
Updated on 14-Apr-2020 08:50:24

4K+ Views

In JavaFX, the text node is represented by the Javafx.scene.text.Text class. To insert/display text in JavaFx window you need to −Instantiate the Text class.Set the basic properties like position and text string, using the setter methods or, bypassing them as arguments to the constructor.Add the created node to the Group object.The strikethrough property of the javafx.scene.text.Text class determines whether each line of the text should have a straight line passing through the middle of it. You can set the value to this property using the setStrikeThrough() method. It accepts a boolean value. You can strike though the text (node) by ... Read More

Adjust Line Spacing in Text Node in JavaFX

Maruthi Krishna
Updated on 14-Apr-2020 08:48:00

2K+ Views

The line spacing property of the javafx.scene.text.The text class specifies the line spacing between the lines of the text (node) vertically.You can set the value to this property using the setLineSpacing() method. This method accepts a boolean value as a parameter and sets the specified space between the lines (vertically).Exampleimport java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.InputStream; import java.util.Scanner; import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.paint.Color; import javafx.stage.Stage; import javafx.scene.text.Text; import javafx.scene.text.TextAlignment; public class TextSpacing extends Application {    public void start(Stage stage) throws FileNotFoundException {       //Reading the contents of a text file.       InputStream inputStream ... Read More

Advertisements