关于锁的一些内容与整理
std::mutex std::mutex:最基本的mutex类。 std::recursive_mutex:递归mutex类,能多次锁定而不死锁。 std::time_mutex:定时mutex类,可以锁定一定的时间。 std::recursive_timed_mutex:定时递归mutex类。 另外,还提供了两种锁类型: std::lock_guar...
std::mutex std::mutex:最基本的mutex类。 std::recursive_mutex:递归mutex类,能多次锁定而不死锁。 std::time_mutex:定时mutex类,可以锁定一定的时间。 std::recursive_timed_mutex:定时递归mutex类。 另外,还提供了两种锁类型: std::lock_guar...
记录一下遇到的三个位操作的训练,学习大佬的智慧! Problems You may ONLY use bitwise operations such as and (&), or (|), xor (^), not (~), left shifts («), and right shifts (»). You may not use any for/while loops or c...
Lambda [capture](parameters) -> return_type { // 函数体 } Function pointers #include <iostream> // 定义一个函数原型 int add(int a, int b) { return a + b; } int subtract(int a, int b) { ...
Template Classes 语法的例子: //mypair.h template<typename First, typename Second> class MyPair { public: First getFirst(); Second getSecond(); void setFirst(First f); void setSecond(Seco...
WHAT IS AN OBJECT? An Object is an instance of a Class. When a class is defined, no memory is allocated but when it is instantiated (i.e. an object is created) memory is allocated. A class w...
All containers are collections of objects All containers implement iterators, but they’re not all the same! All iterators implement a few shared operations: Initializing -> iter =...
Streams stream: an abstraction for input/output. Streams convert between data and the string representation of data. std::coutis an output stream .It has type std::ostream Two ways to classify s...
Generic Methods 例子 public static <K,V> V get(Map61B<K,V> map, K key) { if map.containsKey(key) { return map.get(key); } return null; } 在type未知的情况下引用Comparable,下面的e...
Uniform initialization curly bracket initialization. Available for all types, immediate initialization on declaration! 可以使用等号,也可以不使用 以下是例子: std::vector vec{1,3,5}; std::pair numSuffix1{1,"st"}; St...
Caveats of autoboxing and unboxing Arrays are never autoboxes or auto-unboxed, e.g. if you have an array of integers int[] x, and try to put its address into a variable of type Integer[], ...