Tutorial by Examples: c

An example implementation of BubbleSort in C++: void bubbleSort(vector<int>numbers) { for(int i = numbers.size() - 1; i >= 0; i--) { for(int j = 1; j <= i; j++) { if(numbers[j-1] > numbers[j]) { swap(numbers[j-1],numbers(...
Download the .jar file from vaadin add-ons And put it in the lib folder of WEB-INF then right click on the .jar file and click on to Build Path --> Add To Build Path
public class QuickSort { private static int Partition(int[] input, int low, int high) { var pivot = input[high]; var i = low - 1; for (var j = low; j <= high - 1; j++) { if (input[j] <= pivot) { i++; ...
In C, all arguments are passed to functions by value, including structs. For small structs, this is a good thing as it means there is no overhead from accessing the data through a pointer. However, it also makes it very easy to accidentally pass a huge struct resulting in poor performance, particula...
An example of a constraint as expressed in the C standard is having two variables of the same name declared in a scope1), for example: void foo(int bar) { int var; double var; } This code breaches the constraint and must produce a diagnostic message at compile time. This is very usef...
The unary + and - operators are only usable on arithmetic types, therefore if for example one tries to use them on a struct the program will produce a diagnostic eg: struct foo { bool bar; }; void baz(void) { struct foo testStruct; -testStruct; /* This breaks the constraint so mu...
We have a DataListComponent that shows a data we pull from a service. DataListComponent also has a PagerComponent as it's child. PagerComponent creates page number list based on total number of pages it gets from the DataListComponent. PagerComponent also lets the DataListComponent know when user c...
Consider this example: private void button1_Click(object sender, EventArgs e) { label1.Text = RunTooLong(); } This method will freeze UI application until the RunTooLong will be completed. The application will be unresponsive. You can try run inner code asynchronously: private void butt...
Carthage Setup Download the latest version of Carthage from the given link Download Link Down in the Download section download the Carthage.pkg file. Once the download is complete install it by double clinking on the download pkg file. To check for successful download run the following command i...
Here I have shared a code snippet for implementing endless scrolling in recycle view. Step 1: First make a one abstract method in Recycleview adapter like below. public abstract class ViewAllCategoryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { public abstract void lo...
DECLARE @ID AS INT; SET @ID = (SELECT MIN(ID) from TABLE); WHILE @ID IS NOT NULL BEGIN PRINT @ID; SET @ID = (SELECT MIN(ID) FROM TABLE WHERE ID > @ID); END
RwLocks allow a single producer provide any number of readers with data while preventing readers from seeing invalid or inconsistent data. The following example uses RwLock to show how a single producer thread can periodically increase a value while two consumers threads are reading the value. use...
Catalan numbers algorithm is Dynamic Programming algorithm. In combinatorial mathematics, the Catalan numbers form a sequence of natural numbers that occur in various counting problems, often involving recursively-defined objects. The Catalan numbers on nonnegative integers n are a set of numbers t...
A palindrome is a word that can be read both ways, like 'kayak'. This example will show how to find if a given word is a palindrome using Python3. First, we need to turn a string into a stack (we will use arrays as stacks). str = "string" stk = [c for c in str] #this makes an array: [&...
According to Wikipedia: [A] software design pattern is a general reusable solution to a commonly occurring problem within a given context in software design. It is not a finished design that can be transformed directly into source or machine code. It is a description or template for how to solve ...
Viewchild offers one way interaction from parent to child. There is no feedback or output from child when ViewChild is used. We have a DataListComponent that shows some information. DataListComponent has PagerComponent as it's child. When user makes a search on DataListComponent, it gets a data fro...
To retrieve information about dplyr package and its functions' descriptions: help(package = "dplyr") No need to load the package first.
To see built-in data sets from package dplyr data(package = "dplyr") No need to load the package first.
To get the list of functions within package dplyr, we first must load the package: library(dplyr) ls("package:dplyr")
If you want to create a custom validation rule, you can do so for instance in the boot method of a service provider, via the Validator facade. <?php namespace App\Providers; use Illuminate\Support\ServiceProvider; use Validator; class AppServiceProvider extends ServiceProvider { ...

Page 612 of 826