Hash Pragma Directive in C/C++

Ankith Reddy
Updated on 25-Jun-2020 09:50:00

3K+ Views

The preprocessor directive #pragma is used to provide the additional information to the compiler in C/C++ language. This is used by the compiler to provide some special features.Here is the syntax of #pragma directive in C/C++ language, #pragma token_nameThe table of some of #pragma directives in C/C++ language is given as follows, Sr.No.#pragma Directives & Description1#pragma startupBefore the execution of main(), the function specified in pragma is needed to run.2#pragma exitBefore the end of program, the function specified in pragma is needed to run.3#pragma warnUsed to hide the warning messages.4#pragma GCC dependencyChecks the dates of current and other file. If ... Read More

Copy All Elements of Java HashSet to an Object Array

karthikeya Boyini
Updated on 25-Jun-2020 09:49:16

330 Views

Declare a HashSet and add elements −Set hs = new HashSet(); hs.add(15); hs.add(71); hs.add(82); hs.add(89); hs.add(91); hs.add(93); hs.add(97); hs.add(99);To copy all the elements, use the toArray() method −Object[] obArr = hs.toArray();The following is an example to copy all elements to HashSet to an object array −Example Live Demoimport java.util.*; public class Demo {    public static void main(String args[]) {       Set hs = new HashSet();       hs.add(15);       hs.add(71);       hs.add(82);       hs.add(89);       hs.add(91);       hs.add(93);       hs.add(97);       hs.add(99);   ... Read More

Get Size of HashSet in Java

Samual Sam
Updated on 25-Jun-2020 09:48:14

365 Views

To get the size of HashSet, use the size() method. Let us create a HashSet and add elements −Set hs = new HashSet(); hs.add(15); hs.add(71); hs.add(82); hs.add(89); hs.add(91);Let us now use size() and get the size of HashSet −hs.size()The following is an example to get the size of HashSet −Example Live Demoimport java.util.*; public class Demo {    public static void main(String args[]) {       Set hs = new HashSet();       hs.add(15);       hs.add(71);       hs.add(82);       hs.add(89);       hs.add(91);       System.out.println("Elements = "+hs);       ... Read More

Iterate Through Elements of HashSet in Java

karthikeya Boyini
Updated on 25-Jun-2020 09:47:33

405 Views

Create a HashSet and add elements to it −Set hs = new HashSet(); hs.add(20); hs.add(39); hs.add(67); hs.add(79); hs.add(81); hs.add(87);Try the below given code to iterate through the elements −Iterator i = hs.iterator(); while (i.hasNext()) System.out.println(i.next());To iterate through the elements of HashSet, try the following code −Example Live Demoimport java.util.*; public class Demo {    public static void main(String args[]) {       Set hs = new HashSet();       hs.add(20);       hs.add(39);       hs.add(67);       hs.add(79);       hs.add(81);       hs.add(87);       hs.add(88);       System.out.println("Elements = ... Read More

Remove Specified Element from HashSet in Java

Samual Sam
Updated on 25-Jun-2020 09:46:23

479 Views

To remove specified element from HashSet, use the remove() method.First, declare a HashSet and add elements −Set hs = new HashSet(); hs.add(20); hs.add(39); hs.add(67); hs.add(79); hs.add(81); hs.add(87); hs.add(88);Let’s say you need to remove element 39. For that, use the remove() method −hs.remove(39);The following is an example to remove specified element from HashSet −Example Live Demoimport java.util.*; public class Demo {    public static void main(String args[]) {       Set hs = new HashSet();       hs.add(20);       hs.add(39);       hs.add(67);       hs.add(79);       hs.add(81);       hs.add(87);     ... Read More

Iterate Over Elements of HashSet in Java

karthikeya Boyini
Updated on 25-Jun-2020 09:45:39

307 Views

Declare a HashSet and add elements −Set hs = new HashSet(); hs.add(20); hs.add(39); hs.add(67); hs.add(79);Now, iterate over the elements −for (Iterator i = hs.iterator(); i.hasNext();) {    Object ele = i.next();    System.out.println(ele); }The following is an example that iterate over the elements of HashSet −Example Live Demoimport java.util.HashSet; import java.util.Iterator; import java.util.Set; public class Demo {    public static void main(String[] argv) throws Exception {       Set hs = new HashSet();       hs.add(20);       hs.add(39);       hs.add(67);       hs.add(79);       System.out.println("Elements = ");       for (Iterator ... Read More

Is the Think Operator Faster than in C/C++?

Arjun Thakur
Updated on 25-Jun-2020 09:45:25

1K+ Views

No, the operator < takes same time to execute as operator

ArrayBuffer byteLength Property in JavaScript

Samual Sam
Updated on 25-Jun-2020 09:43:36

681 Views

ArrayBuffer object in JavaScript represents a fixed-length binary data buffer.The byteLength property of the ArrayBuffer returns an unsigned, 32-bit integer that specifies the size/length of the ArrayBuffer.SyntaxIts syntax is as followsarray.byteLengthExampleTry the following example. Live Demo JavaScript Example           var arrayBuffer = new ArrayBuffer(8);       var result = arrayBuffer.byteLength;       document.write("length of the array buffer is: " + result);     Outputlength of the array buffer is: 8ExampleYou can also create an array buffer object by passing a string value and get its length as in the following example. ... Read More

isless Function in C/C++

Arjun Thakur
Updated on 25-Jun-2020 09:42:06

387 Views

The function isless() is used to check that first argument is less than the second one. It is declared in “math.h” header file in C language. It returns true if successful otherwise it returns false.Here is the syntax of isless() in C language, bool isless(value1 , value2);Here, value1 − This is the first argument which will be checked with value2.value2 − This is the second argument which is used to check value1 ans see that it is less or not.Here is an example of isless() in C language, Example Live Demo#include #include int main() {    int val1 = 48; ... Read More

islessgreater in C/C++

George John
Updated on 25-Jun-2020 09:40:25

261 Views

The function islessgreater() is used to check that first argument is less than or greater than the second one. It is declared in “math.h” header file in C language. It returns true, if successful otherwise false.Here is the syntax of islessgreater() in C++ language, bool islessgreater(value1 , value2);Here, value1 − This is the first argument which will be checked with value2.value2 − This is the second argument which is used to check value1 and see that is less or greater.Here is an example of islessgreater() in C++ language, Example Live Demo#include #include using namespace std; int main() {    int ... Read More

Advertisements