program-language
jarvis4tonny
你说月亮好美。
展开
-
c++ STL string类仿写
最近看string类成员函数的时候,想着自己实现一下类似的字符串类。写了下,大体上粗略的实现了常见的函数,运算符等。嫌麻烦,有些函数没写重载形式了。主要是封装一个char* 指针,对其作操作。代码如下:#include <iostream>#include <cstring>using namespace std;class MyString{public: class Iterat原创 2016-03-04 13:37:29 · 883 阅读 · 0 评论 -
Python调用C++的一种方法
1.单独编译python文件 python -m py_compile file.py //编译一个文件 python -m py_compile /root/src/{file1,file2}.py //编译一个文件夹内的文件2.Python调用C++a.通过c原创 2016-05-16 20:06:23 · 494 阅读 · 0 评论 -
C语言双向循环链表实现
实现思路:插入时候不是插入节点而是数据,通过自己提供的compare,和print函数进行特定类型的操作。而其余操作均可以定义一种通用的做法。#include <stdio.h>#include <stdlib.h>typedef struct linknode{ void* data; struct linknode* prev; struct linknode* nex原创 2016-05-16 20:10:50 · 662 阅读 · 0 评论 -
智能指针粗略实现
C++智能指针粗略实现template<typename T>class Auto_Ptr{public: Auto_Ptr<T>(T *p) : p_val(p), p_cnt(new P_Cnt){} ~Auto_Ptr(); T& operator*(){ return *p_val; } T* operator->(){ return p_val; }原创 2016-07-27 21:41:25 · 231 阅读 · 0 评论 -
C++ Prefix Tree 粗略实现
做leetcode的时候写的这个。#include<string>#include<algorithm>using std::string;class TrieNode {public: // Initialize your data structure here. TrieNode() { for (TrieNode* &p : next){原创 2016-07-20 09:27:40 · 514 阅读 · 0 评论