AsyncTaskLoader is an abstract Loader that provides an AsyncTask to do the work.
Here some basic implementation:
final class BasicLoader extends AsyncTaskLoader<String> {
public BasicLoader(Context context) {
super(context);
}
@Override
public String loadInBa...
In C++, a byte is the space occupied by a char object. The number of bits in a byte is given by CHAR_BIT, which is defined in climits and required to be at least 8. While most modern systems have 8-bit bytes, and POSIX requires CHAR_BIT to be exactly 8, there are some systems where CHAR_BIT is great...
There are two possible ways to pass a value type by reference: ref and out. The difference is that by passing it with ref the value must be initialized but not when passing it with out. Using out ensures that the variable has a value after the method call:
public void ByRef(ref int value)
{
C...
It is not possible to directly use static_cast, const_cast, dynamic_cast and reinterpret_cast on std::shared_ptr to retrieve a pointer sharing ownership with the pointer being passed as argument. Instead, the functions std::static_pointer_cast, std::const_pointer_cast, std::dynamic_pointer_cast and ...
Imagine you have all dates in all responses in some custom format, for instance /Date(1465935152)/ and you want apply general rule to deserialize all Json dates to java Date instances. In this case you need to implement custom Json Deserializer.
Example of json:
{
"id": 1,
"cr...
Of the LINQ methods which use deferred execution, some require a single value to be evaluated at a time. The following code:
var lst = new List<int>() {3, 5, 1, 2};
var streamingQuery = lst.Select(x => {
Console.WriteLine(x);
return x;
});
foreach (var i in streamingQuery) {
...
For the sake of data encapsulation, sometimes you want to have an attribute which value comes from other attributes or, in general, which value shall be computed at the moment. The standard way to deal with this situation is to create a method, called getter or a setter.
class Book:
def __init...
When a function doesn't preserve units automatically due to lower-level operations, the LanguagePrimitives module can be used to set units on the primitives that support them:
/// This cast preserves units, while changing the underlying type
let inline castDoubleToSingle (x : float<'u>) : fl...
The [<Measure>] attribute can be used on type parameters to declare types that are generic with respect to units of measure:
type CylinderSize<[<Measure>] 'u> =
{ Radius : float<'u>
Height : float<'u> }
Test usage:
open Microsoft.FSharp.Data.UnitSystems...
class User {
String name
int age
}
def users = [
new User(name: "Bob", age: 20),
new User(name: "Tom", age: 50),
new User(name: "Bill", age: 45)
]
// sort by age
users.sort { a, b -> a.age <=> b.age }
All values in Rust have exactly one owner. The owner is responsible for dropping that value when it goes out of scope, and is the only one who may move the ownership of the value. The owner of a value may give away references to it by letting other pieces of code borrow that value. At any given time...
Most of the questions around ownership come up when writing functions. When you specify the types of a function's arguments, you may choose how that value is passed in. If you only need read-only access, you can take an immutable reference:
fn foo(x: &String) {
// foo is only authorized to...
Some Rust types implement the Copy trait. Types that are Copy can be moved without owning the value in question. This is because the contents of the value can simply be copied byte-for-byte in memory to produce a new, identical value. Most primitives in Rust (bool, usize, f64, etc.) are Copy.
let x...
def honestlyNoParam = { ->
"I Don't have it"
}
// The following all throw IllegalArgumentException
honestlyNoParam.curry('whatever')
honestlyNoParam.rcurry('whatever')
honestlyNoParam.ncurry(0, 'whatever')
This example shows how to establish a connection to an SSL-enabled POP3 email server and send a simple (text only) email.
// Configure mail provider
Properties props = new Properties();
props.put("mail.smtp.host", "smtp.mymailprovider.com");
props.put("ma...
Because generating documentation is based on markdown, you have to do 2 things :
1/ Write your doctest and make your doctest examples clear to improve readability (It is better to give a headline, like "examples" or "tests"). When you write your tests, do not forget to give 4 s...
How to get the average amount of debit and credit transactions?
> db.transactions.aggregate(
[
{
$group : {
_id : '$cr_dr', // group by type of transaction (debit or credit)
count : {$sum : 1}, // number of transaction for each type...
Specifies how the database generates values for the property. There are three possible values:
None specifies that the values are not generated by the database.
Identity specifies that the column is an identity column, which is typically used for integer primary keys.
Computed specifies that th...