ARTS 打卡 -07
Algorithm
Question
Plus One
Given a non-empty array of digits representing a non-negative integer, increment one to the integer.
The digits are stored such that the most significant digit is at the head of the list, and each element in the array contains a single digit.
You may assume the integer does not contain any leading zero, except the number 0 itself.
My answer
Review
Apache Cassandra
https://www.datastax.com/cassandra
Apache Cassandra is an open source, distributed NoSQL database that began internally at Facebook and was released as an open-source project in July 2008. Cassandra delivers continuous availability (zero downtime), high performance, and linear scalability that modern applications require, while also offering operational simplicity and effortless replication across data centers and geographies. Cassandra can handle petabytes of information and thousands of concurrent operations per second, enabling organizations to manage large amounts of data across hybrid cloud and multi cloud environments.
At DataStax, we’re working hard with the open-source community to build on Cassandra’s decade-plus of maturity to solidify its position as the leading database for cloud-native applications.
Tips
1. tmux
Install
sudo apt-get install tmux
Create a session
tmux new -s <session_name>
List out all the running sessions
tmux ls
Attach to a running session
tmux attach -t <session_name>
tmux a -t <session_name>
2. git patch
https://www.tutorialspoint.com/git/git_patch_operation.htm
Patch is a text file, whose contents are similar to Git diff, but along with code, it also has metadata about commits; e.g., commit ID, date, commit message, etc. We can create a patch from commits and other people can apply them to their repository.
Create patches for the latest N commits
git format-patch -N
Create a patch for a specific commit
git format-patch <commit_ID>
The above commands create .patch files inside the current working directory.
Modify the local files without creating commit
git apply <patch_name>.patch
Modify the file and create commit as well
git am <patch_name>.patch
Share
1. std::move()
https://stackoverflow.com/questions/3413470/what-is-stdmove-and-when-should-it-be-used
"What is it?"
While std::move()
is technically a function - I would say it isn't really a function. It's sort of a converter between ways the compiler considers an expression's value.
"What does it do?"
The first thing to note is that std::move()
doesn't actually move anything. It converts an expression from being an lvalue (such as a named variable) to being an xvalue. An xvalue tells the compiler:
You can plunder me, move anything I'm holding and use it elsewhere (since I'm going to be destroyed soon anyway)".
in other words, when you use std::move(x)
, you're allowing the compiler to cannibalize x
. Thus if x
has, say, its own buffer in memory - after std::move()
ing the compiler can have another object own it instead.
"When should it be used?"
A typical use is 'moving' resources from one object to another instead of copying.
2. std::bind() & placeholders
https://www.geeksforgeeks.org/bind-function-placeholders-c/
How does bind() work?
Bind function with the help of placeholders, helps to manipulate the position and number of values to be used by the function and modifies the function according to the desired output.
What are placeholders?
Placeholders are namespace which direct the position of a value in a function. They are represented by _1, _2, _3…
评论