Delete a Linked List in C++ Programming

sudhir sharma
Updated on 15-Jul-2020 06:21:31

683 Views

Here, we will create a function that will delete all elements of a linked list one by one.In c/c++, there is no specific function to perform this task but in java, the automatic garbage collection is done to ease deleting linked list.Now, let’s see the implementation of this program, Example Live Demo#include using namespace std; class Node{    public:    int data;    Node* next; }; void deleteLinkedList(Node** head_ref){    Node* current = *head_ref;    Node* next;    while (current != NULL){       coutnext = (*head_ref);    (*head_ref) = new_node; } int main(){    Node* head = NULL; ... Read More

Implement Long to Int Function Using Lambda and Method Reference in Java

raja
Updated on 15-Jul-2020 04:59:08

216 Views

LongToIntFunction is a functional interface from java.util.function package introduced in Java 8. This functional interface accepts a long-valued parameter as input and produces an int-valued result. LongToIntFunction interface can be used as an assignment target for a lambda expression or method reference. This interface contains only one abstract method: applyAsInt() and doesn't contain any default and abstract methods.Syntax@FunctionalInterface interface LongToIntFunction {    int applyAsInt(long value); }Example of Lambda Expressionimport java.util.function.LongToIntFunction; public class LongToIntLambdaTest {    public static void main(String args[]) {       LongToIntFunction getInt = longVal -> {     // lambda expression          int intVal = (int)longVal;       ... Read More

Implement LongToDoubleFunction Using Lambda and Method Reference in Java

raja
Updated on 15-Jul-2020 04:58:24

138 Views

LongToDoubleFunction is a built-in functional interface and part of java.util.function package. This functional interface accepts a long-valued parameter as input and produces a double-valued result. LongToDoubleFunction can be used as an assignment target for a lambda expression or method reference. It contains only one abstract method: applyAsDouble().Syntax@FunctionalInterface interface LongToDoubleFunction {  double applyAsDouble(long value); }Example of Lambda Exampleimport java.util.function.LongToDoubleFunction; public class LongToDoubleLambdaTest {    public static void main(String args[]) {       LongToDoubleFunction getDouble = longVal -> { // lambda expression          double doubleVal = longVal;          return doubleVal;       };       long input = ... Read More

Implement intToLong Function Using Lambda and Method Reference in Java

raja
Updated on 15-Jul-2020 04:56:16

167 Views

IntToLongFunction is a built-in functional interface from java.util.function package. This functional interface accepts an int-valued parameter and produces a long-valued result. IntToLongFunction interface can be used as an assignment target for a lambda expression or method reference. It contains only one abstract method: applyAsLong().Syntax@FunctionalInterface interface IntToLongFunction {  long applyAsLong(int value); }Example of Lambda Expressionimport java.util.function.IntToLongFunction; public class IntToLongFunctionLambdaTest {    public static void main(String args[]) {       IntToLongFunction getLong = intVal -> {      // lambda expression          long longVal = intVal;          return longVal;       };           int input = 40; ... Read More

Disable Future Dates in JavaScript Datepicker

AmitDiwan
Updated on 14-Jul-2020 17:20:31

14K+ Views

In order to disable future dates, you need to use maxDate and set the current date. Following is the JavaScript code −Example Live Demo Document The selected date is as follows:    $(document).ready(function () {       var currentDate = new Date();       $('.disableFuturedate').datepicker({       format: 'dd/mm/yyyy',       autoclose:true,       endDate: "currentDate",       maxDate: currentDate       }).on('changeDate', function (ev) {          $(this).datepicker('hide');       });       $('.disableFuturedate').keyup(function () {     ... Read More

Disable Default Behavior of Input Type Time with JavaScript

AmitDiwan
Updated on 14-Jul-2020 17:18:15

324 Views

For this, you need to use keyDown as well as preventDefault(). Following is the JavaScript code −Example Live Demo Document    const pressEnter = (event) => {       if (event.key === "Enter") {          event.preventDefault();       }    };    document.getElementById("disableDefaultTime").addEventListener("keydown",    pressEnter); To run the above program , just save the file name anyName.html(index.html) and right click on the file and select the option open with live server in VSCode editor.OutputFollowing is the output. When you press Enter key nothing will be displayed.You need to use keyDown to get time as in the below screenshot −

jQuery val() Change Doesn't Change Input Value

AmitDiwan
Updated on 14-Jul-2020 17:17:38

3K+ Views

For this, you need to use attr(). The attr() method can be used to either fetch the value of an attribute from the first element in the matched set or set attribute values onto all matched elements.Following is the JavaScript code −Example Live Demo Document $('#myURL').attr('value', 'http://www.facebook.com'); To run the above program, just save the file name anyName.html(index.html) and right click on the file and select the option open with live server in VSCode Editor.OutputLook at the above sample output the URL has been changed ... Read More

Implement IntToDoubleFunction Using Lambda and Method Reference in Java

raja
Updated on 14-Jul-2020 13:58:35

215 Views

IntToDoubleFunction is a functional interface from java.util.function package. This functional interface accepts an int-valued argument and produces a double-valued result. IntToDoubleFunction can be used as an assignment target for a lambda expression or method reference. It contains only one abstract method: applyAsDouble().Syntax@FunctionalInterface interface IntToDoubleFunction {    double applyAsDouble(int value); }Example of Lambda Expressionimport java.util.function.IntToDoubleFunction;; public class IntToDoubleLambdaTest {    public static void main(String[] args) {       IntToDoubleFunction getDouble = intVal -> {      // lambda expression          double doubleVal = intVal;          return doubleVal;       };       int input ... Read More

Implement DoubleToIntFunction Using Lambda Expression in Java

raja
Updated on 14-Jul-2020 13:55:31

343 Views

DoubleToIntFunction is a functional interface defined in java.util.function package introduced in Java 8 version. This functional interface accepts a double-valued argument and produces an int-valued result. DoubleToIntFunction interface can be used as an assignment target for a lambda expression or method reference. It contains only one abstract method: applyAsInt().Syntax@FunctionalInterface interface DoubleToIntFunction {  int applyAsInt(double value) }Exampleimport java.util.function.DoubleToIntFunction; public class DoubleToIntFunctionTest {    public static void main(String args[]) {       DoubleToIntFunction test = doubleVal -> {     // lambda expression          int intVal = (int) doubleVal;          return intVal;       };       ... Read More

Implement DoubleToLongFunction Using Lambda Expression in Java

raja
Updated on 14-Jul-2020 13:54:53

266 Views

DoubleToLongFunction is a built-in functional interface from java.util.function package introduced in Java 8. This functional interface accepts a double-valued parameter and produces a long-valued result. DoubleToLongFunction interface can be used as an assignment target for a lambda expression or method reference. It contains only one abstract method: applyAsLong().Syntax@FunctionalInterface public interface DoubleToLongFunction {  long applyAsLong(double value) }Exampleimport java.util.function.DoubleToLongFunction; public class DoubleToLongFunctionTest {    public static void main(String args[]) {       double dbl = 30.1212;       DoubleToLongFunction castToLong = (dblValue) -> (long) dblValue; // lambda expression       System.out.println(castToLong.applyAsLong(dbl));       dbl = 77.9212;       DoubleToLongFunction roundToLong = Math::round;     ... Read More

Advertisements