如何将PascalCase字符串转换为underscore_case字符串?我也需要将点转换为下划线.
例如.兑换
TypeOfData.AlphaBeta
Run Code Online (Sandbox Code Playgroud)
成
type_of_data_alpha_beta
Run Code Online (Sandbox Code Playgroud) 是否有任何内联命令在MATLAB中生成移位的单位矩阵?
A=[ ...
0, 1, 0, 0, 0, 0, 0, 0, 0, 0
0, 0, 1, 0, 0, 0, 0, 0, 0, 0
0, 0, 0, 1, 0, 0, 0, 0, 0, 0
0, 0, 0, 0, 1, 0, 0, 0, 0, 0
0, 0, 0, 0, 0, 1, 0, 0, 0, 0
0, 0, 0, 0, 0, 0, 1, 0, 0, 0
0, 0, 0, 0, 0, 0, 0, 1, 0, 0
0, 0, 0, 0, 0, 0, 0, …Run Code Online (Sandbox Code Playgroud) 假设链接列表以这种方式定义:
template <typename Object>
struct Node{
Object data;
Node *prev;
Node *next;
Node(const Object & d = Object(), Node *p = NULL, Node *n = NULL)
: data(d), prev(p),next(n){}
};
template <typename Object>
class List
{
public:
iterator begin(){return iterator(head->next);}
iterator end(){return iterator(tail);}
....
private:
Node *head=nullptr;
Node *tail=nullptr;
...
Run Code Online (Sandbox Code Playgroud)
迭代器:
class iterator
{
public:
iterator():current(NULL){}
Object & operator*(){return retrieve();}
iterator & operator++()
{
current = current->next;
return *this;
}
....
private:
Node *current;
...
Run Code Online (Sandbox Code Playgroud)
此代码中存在问题.
for(iterator<Object> itr = list.begin(); …Run Code Online (Sandbox Code Playgroud)