Tutorial by Examples: ect

We can provide a consumer that will be called with the multiple relevant values: C++11 template <class F> void foo(int a, int b, F consumer) { consumer(a + b, a - b, a * b, a / b); } // use is simple... ignoring some results is possible as well foo(5, 12, [](int sum, int , int , i...
Inject and reduce are different names for the same thing. In other languages these functions are often called folds (like foldl or foldr). These methods are available on every Enumerable object. Inject takes a two argument function and applies that to all of the pairs of elements in the Array. For...
The ForEach-Object cmdlet works similarly to the foreach statement, but takes its input from the pipeline. Basic usage $object | ForEach-Object { code_block } Example: $names = @("Any","Bob","Celine","David") $names | ForEach-Object { "H...
Vector size is simply the number of elements in the vector: Current vector size is queried by size() member function. Convenience empty() function returns true if size is 0: vector<int> v = { 1, 2, 3 }; // size is 3 const vector<int>::size_type size = v.size(); cout << size...
One std::vector can be append to another by using the member function insert(): std::vector<int> a = {0, 1, 2, 3, 4}; std::vector<int> b = {5, 6, 7, 8, 9}; a.insert(a.end(), b.begin(), b.end()); However, this solution fails if you try to append a vector to itself, because the sta...
<PROJECT_ROOT>\app\build.gradle is specific for app module. <PROJECT_ROOT>\build.gradle is a "Top-level build file" where you can add configuration options common to all sub-projects/modules. If you use another module in your project, as a local library you would have another...
A std::vector automatically increases its capacity upon insertion as needed, but it never reduces its capacity after element removal. // Initialize a vector with 100 elements std::vector<int> v(100); // The vector's capacity is always at least as large as its size auto const old_capacity...
You can use an instance of an object to form your parameters public class SearchParameters { public string SearchString { get; set; } public int Page { get; set; } } var template= new SearchParameters { SearchString = "Dapper", Page = 1 }; var p = new DynamicParameters...
# test date-time object options(digits.secs = 3) d = as.POSIXct("2016-08-30 14:18:30.58", tz = "UTC") format(d,"%S") # 00-61 Second as integer ## [1] "30" format(d,"%OS") # 00-60.99… Second as fractional ## [1] "30.579" for...
The functions for parsing a string into POSIXct and POSIXlt take similar parameters and return a similar-looking result, but there are differences in how that date-time is stored; see "Remarks." as.POSIXct("11:38", # time string format = "...
Long vectors with long runs of the same value can be significantly compressed by storing them in their run-length encoding (the value of each run and the number of times that value is repeated). As an example, consider a vector of length 10 million with a huge number of 1's and only a small number o...
The SQL 2008 standard defines the FETCH FIRST clause to limit the number of records returned. SELECT Id, ProductName, UnitPrice, Package FROM Product ORDER BY UnitPrice DESC FETCH FIRST 10 ROWS ONLY This standard is only supported in recent versions of some RDMSs. Vendor-specific non-stand...
Pojo Model public class Model { private String firstName; private String lastName; private int age; /* Getters and setters not shown for brevity */ } Example: String to Object Model outputObject = objectMapper.readValue( "{\"firstName\":\"J...
It's possible to attach an object to an existing object as if there was a new property. This is called association and allows one to extend existing objects. It can be used to provide storage when adding a property via a class extension or otherwise add additional information to an existing object. ...
To select the children of an element you can use the children() method. <div class="parent"> <h2>A headline</h2> <p>Lorem ipsum dolor sit amet...</p> <p>Praesent quis dolor turpis...</p> </div> Change the color of all the ...
Sometimes it's not a good practice expose an internal collection since it can lead to a malicious code vulnerability due to it's mutable characteristic. In order to provide "read-only" collections java provides its unmodifiable versions. An unmodifiable collection is often a copy of a mod...
Consider the following tough-to-vectorize for loop, which creates a vector of length len where the first element is specified (first) and each element x_i is equal to cos(x_{i-1} + 1): repeatedCosPlusOne <- function(first, len) { x <- numeric(len) x[1] <- first for (i in 2:len) { ...
By default, the various Collection types are not thread-safe. However, it's fairly easy to make a collection thread-safe. List<String> threadSafeList = Collections.synchronizedList(new ArrayList<String>()); Set<String> threadSafeSet = Collections.synchronizedSet(new HashSet<S...
Now that the routes are set up, we need some way to actually change routes. This example will show how to change routes using the template, but it is possible to change routes in TypeScript. Here is one example (without binding): <a routerLink="/home">Home</a> If the user...
General syntax git push <remotename> <object>:<remotebranchname> Example git push origin master:wip-yourname Will push your master branch to the wip-yourname branch of origin (most of the time, the repository you cloned from). Delete remote branch Deleting the remote br...

Page 10 of 99