Init react Commend
1 npx create-react-app . npx means you use this package but don’t download it.
or with redux
1 npx create-react-app my-app --template redux life cycle Class component lifecycle Function component method shouldComponentUpdate() Run before render() to check this component need to render or not.
1 2 3 shouldComponentUpdate(nextProps, nextStates){ return boolean; } PureComponent can automatically do a shallow comparison to determine need to update or not
export default React.
Monitor signal condition –> waiting monitor –> signaling
producer and consumer with a buffer whose size is one 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 monitor PC { Object buffer; void produce(Object o){ if(buffer != null){ // while empty.wait(); } buffer = o; full.signal(); } Object consume() { if(buffer == null) // while full.wait(); Object temp = buffer; empty.
Content Content Algorithm Overview Copy For each Generation Heap Merge Move Number Partition Permutation Remove Replace Reverse rotate Search Set Shuffle Sort Swap Test range Unique Algorithm Overview * –> new feature from C++11
Algorithm Name Usage Mutating? Head File Complexity accumulate Accumulate values in range N numeric O(n) adjacent_difference Compute adjacent difference of range and return to another place N numeric O(n) adjacent_find Find first equal adjacent elements in range N algorithm O(n) all_of* Test condition on all elements in range N algorithm O(n) any_of* Test if any element in range fulfills condition N algorithm O(n) binary_search Test if value exists in sorted sequence N algorithm On average O(logn + 2).
SCSS features Variables 1 2 3 4 5 6 7 $font-stack: Helvetica, sans-serif; $primary-color: #333; body { font: 100% $font-stack; color: $primary-color; } Operator 1 2 3 4 5 6 7 8 9 10 11 12 13 .container { width: 100%; } article[role='main'] { float: left; width: 600px / 960px * 100%; } article[role='complementary'] { float: right; width: 300px / 960px * 100%; } String interpolation 1 2 3 4 5 $name: foo; $attr: border; p.
Semaphore Initialize how many permissions you will use.
acquire() will add one permission.
release() will remove one permission.
Permission must ≥ 0.
Semaphore solution for the MEP #criticalSection + permissions = 1 #criticalSection = #acquires − #releases Mutual exclusion: #criticalSection ≤ 1 since #permission ≥ 0. Absence of deadlock: It never happens that #permission = 0 and #criticalSection = 0
Java 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 public class Turnstile extends Thread { static volatile int counter = 0; // keyword is recommended for variables that are shared static Semaphore mutex = new Semaphore (1); public void run() { for(int i = 0; i < 50; i++){ mutex.
Race condition Multiple thread access one same variables of object concurrently and at least one does update.
Bad situation.
Atomic operation An operation is atomic if it execute until it completion without interruption
Critical section A part of program that accesses shared memory and which we which to execute automatically.
mutual exclusion problem (MEP) Mutex: at and point in time, there is at most one thread in the critical section Absence of livelock: If various of threads try to entry the critical section, at lease one of them will succeed.
Agile Vs Traditional SDLC Models Agile is based on the adaptive software development methods, whereas the traditional SDLC models like the waterfall model is based on a predictive approach. Predictive teams in the traditional SDLC models usually work with detailed planning and have a complete forecast of the exact tasks and features to be delivered in the next few months or during the product life cycle.
Predictive methods entirely depend on the requirement analysis and planning done in the beginning of cycle.
Document constructor $$f(x) = sin(x)$$
What is concurrency Systems of interacting computer programs which share resource and run concurrently.
parallelism and concurrency Parallelism: Occurring physically at the same time.
Concurrency: Occurring logically at the same time.
synchronization Process synchronization: Ensure the instructions are executed in certain order.
Synchronization is irrelevant if processes do not interact with each other.
Concurrency, and hence process synchronized, is useful only when processes interact with each other.
interaction Share memory is kind of interact.
See all algorithm click here Mutating and Non-mutating algorithms Mutating algorithms Mutating algorithms means this algorithm will change the content that iterator pointed to. Like copy, swap, replace, fill, remove, permutation, partition, random shuffling and sort.
If your give these algorithms a const iterator, only error will be returned.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 #include <iostream> #include <vector> using namespace std; int main(int argc, char const *argv[]) { std::vector<int> iv = {22,30,30,17,33,40,17,23,22,12,20}; vector<int>::iterator ib = iv.