Tutorial by Examples: c

To create a build target producing an executable, one should use the add_executable command: add_executable(my_exe main.cpp utilities.cpp) This creates a build target, e.g. make my_exe for GNU make, with the appropriate invocations of the configured compiler to pr...
The =~ operator attempts to match a regular expression (set apart by /) to a string: my $str = "hello world"; print "Hi, yourself!\n" if $str =~ /^hello/; /^hello/ is the actual regular expression. The ^ is a special character that tells the regular expression to start with ...
(Collects 2-3 inputs and combines them into a Tuple) Like BatchBlock, JoinBlock<T1, T2, …> is able to group data from multiple data sources. In fact, that’s JoinBlock<T1, T2, …>’s primary purpose. For example, a JoinBlock<string, double, int> is an ISourceBlock<Tuple<strin...
(Copy an item and send the copies to every block that it’s linked to) Unlike BufferBlock, BroadcastBlock’s mission in life is to enable all targets linked from the block to get a copy of every element published, continually overwriting the “current” value with those propagated to it. Additionally,...
(Readonly variable: Memorizes its first data item and passes out copies of it as its output. Ignores all other data items) If BufferBlock is the most fundamental block in TPL Dataflow, WriteOnceBlock is the simplest. It stores at most one value, and once that value has been set, it will never be r...
(Collects a certain number of total items from 2-3 inputs and groups them into a Tuple of collections of data items) BatchedJoinBlock<T1, T2,…> is in a sense a combination of BatchBlock and JoinBlock<T1, T2,…>. Whereas JoinBlock<T1, T2,…> is used to aggregate one input from each ...
(Select, one-to-one) As with ActionBlock, TransformBlock<TInput, TOutput> enables the execution of a delegate to perform some action for each input datum; unlike with ActionBlock, this processing has an output. This delegate can be a Func<TInput, TOutput>, in which case processing of t...
(foreach) This class can be thought of logically as a buffer for data to be processed combined with tasks for processing that data, with the “dataflow block” managing both. In its most basic usage, we can instantiate an ActionBlock and “post” data to it; the delegate provided at the ActionBlock’s c...
(SelectMany, 1-m: The results of this mapping are “flattened”, just like LINQ’s SelectMany) TransformManyBlock<TInput, TOutput> is very similar to TransformBlock<TInput, TOutput>. The key difference is that whereas a TransformBlock<TInput, TOutput> produces one and only one outpu...
(Groups a certain number of sequential data items into collections of data items) BatchBlock combines N single items into one batch item, represented as an array of elements. An instance is created with a specific batch size, and the block then creates a batch as soon as it’s received that number o...
(FIFO Queue: The data that comes in is the data that goes out) In short, BufferBlock provides an unbounded or bounded buffer for storing instances of T. You can “post” instances of T to the block, which cause the data being posted to be stored in a first-in-first-out (FIFO) order by the block. Yo...
Dim sites() As String = {"Stack Overflow", "Super User", "Ask Ubuntu", "Hardware Recommendations"} Dim query = From x In sites Where x.StartsWith("S") ' result = "Stack Overflow", "Super User" Query will be enumerable objec...
Dim sites() As String = {"Stack Overflow", "Super User", "Ask Ubuntu", "Hardware Recommendations"} Dim query = From x In sites Select x.Length ' result = 14, 10, 10, 24 Query...
Primary Constructor In Scala the primary constructor is the body of the class. The class name is followed by a parameter list, which are the constructor arguments. (As with any function, an empty parameter list may be omitted.) class Foo(x: Int, y: String) { val xy: String = y * x /* now...
Casting an instance of a base class to a subclass as in : b = (B) a; is called narrowing (as you are trying to narrow the base class object to a more specific class object) and needs an explicit type-cast. Casting an instance of a subclass to a base class as in: A a = b; is called widening and does...
If we try to change an object on the UI thread from a different thread we will get a cross-thread operation exception: Private Sub Button_Click(sender As Object, e As EventArgs) Handles MyButton.Click ' Cross thread-operation exception as the assignment is executed on a different thread '...
Random and ThreadLocalRandom are good enough for everyday use, but they have a big problem: They are based on a linear congruential generator, an algorithm whose output can be predicted rather easily. Thus, these two classes are not suitable for cryptographic uses (such as key generation). One can ...
Drag 1 textbox and 1 button Double click the button1 and you will be transferred to the Button1_Click event Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click End Sub End Class Type the name of the object that you want to target, ...
std::ifstream f("file.txt"); if (f) { std::stringstream buffer; buffer << f.rdbuf(); f.close(); // The content of "file.txt" is available in the string `buffer.str()` } The rdbuf() method returns a pointer to a streambuf that can be pushed into buffer...
/** * returns a array of random numbers with no duplicates * @param range the range of possible numbers for ex. if 100 then it can be anywhere from 1-100 * @param length the length of the array of random numbers * @return array of random numbers with no duplicates. */ public static int[] ...

Page 249 of 826