小编zah*_*ati的帖子

Javascript将PascalCase转换为underscore_case

如何将PascalCase字符串转换为underscore_case字符串?我也需要将点转换为下划线.

例如.兑换

TypeOfData.AlphaBeta
Run Code Online (Sandbox Code Playgroud)

type_of_data_alpha_beta
Run Code Online (Sandbox Code Playgroud)

javascript string case-conversion

64
推荐指数
5
解决办法
4万
查看次数

Matlab身份转移矩阵

是否有任何内联命令在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)

binary matlab matrix

11
推荐指数
3
解决办法
2206
查看次数

迭代器循环不计算最后一项

假设链接列表以这种方式定义:

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)

c++ templates iterator

0
推荐指数
1
解决办法
95
查看次数