先贴出代码:
#include"stdafx.h"
template <class T>
class STACK
{
public:
void operator--(int)
{
index--;
}
void operator-(long count)
{
index-=count;
}
void operator+(T value)
{
Push(value);
}
long operator+=(T value)
{
return PushDifferent(value);
}
T&operator[](long addr)
{
if(addr<0)return data[index+1+addr];
return data[addr];
}
public:
STACK()
{...
阅读全文
char *strcpy(char *strDest ,const char * strSrc )
{
if(strDest == NULL || strSrc == NULL)
return 0;
char *address = strSrc;
while((*strDest++ = *strSrc++) != '\0')
NULL;
return addressl;
}
//字符串比较函数,相等返回0,s1大返回正整数,s2大返回负整数int mystrcmp(const char *s1,const char *s2){ while(*s1!='/0'&&*s2!='/0'&&(*s1==*s2)) s1++,s2++; return (*s1)-(*s2);}
//字符...
阅读全文
Directx10和Directx11很多resource类都有个Map()函数,个人感觉它是一个蛮重要的CPU和GPU沟通桥梁。下面以ID3D11DeviceContext::Map()为例讲下。
ID3D11DeviceContext::Map官方解释是:ID3D11DeviceContext::Map Method
Get a pointer to the data contained in a subresource, and deny the GPU access to that subresource.
Syntax
HRESULT Map(
ID3D11Resource *pResource,
UINT Subresource,
D3D11_MA...
阅读全文
几年前曾实现过一个菜鸟版的SuffixTree。最近要用到后缀树处理些问题,认真实现了一个,主要是基于UKKonen的On-Line算法。稍微总结下。
网上关于后缀树介绍的文章有几篇写的挺好的,我就不再费力去做重复工作了。这个只是我的个人总结帖,所以定位是给看了后缀树的简介,知道什么后缀树,然后看了UKKonen的加速文章,有点迷迷糊糊的同学的一个总结帖。
首先国内后缀树介绍有几个博客写的蛮详细的:
http://www.cnblogs...
阅读全文
一些朋友提醒,这次一次放出实现了Ukkonen 的paper的三个优化的完整SuffixTree的代码。看了之前博客的只实现SuffixLink优化的代码,再看这个应该就很简单了。
下面是SuffixTree的头文件SuffixTree.h
#pragma once
#include <vector>
#include <string>
using namespace std;
class SuffixNode
{
public:
vector<SuffixNode*> m_pSons;
SuffixNode* m_pFarther;
SuffixNode* m_pSuffixLi...
阅读全文
HLSL基本以C语言的习惯来写的,但是如果完全以C语言的角度来看,我个人感觉入门最难理解就是顶点着色器和像素着色器的两个函数的参数传递了。
下面以最简单的HLSL中效果框架举例说下自己的理解。
uniform extern float4x4 gWVP;
struct OutputVS
{
float4 posH : POSITION0;
float4 color : COLOR0;
};
OutputVS ColorVS(float3 posL : POSITION0, float4 c : COLOR0)
{
// Zero out our...
阅读全文
在用software center装IDLE时 出错
details 说python2.7-tk是虚拟的包什么的 不懂..
于是用 sudo app-get install python2.7-tk
发现 几个 depended on xx
少什么就安装什么
sudo app-get install xx
于是发现问题
Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
sudo apt-get upda了两次都是同样的问题
想想应该是源的问题 最近好像改过
于是
sudo gedit /etc/apt/sources.list
...
阅读全文
题目骗了啊!!什么 kth big number啊!! 明明是区间第k小啊!!
-----------------------------------------
THE 函数式 线段树 赶紧补基础 - -
#include <cstdio>
#include <cstring>
#include <algorithm>
#define lson st[num].ls
#define rson st[num].rs
using namespace std;
const int MAXN = 100100;
struct node
{
int ls,rs,cnt;
};
struct fSTree
{
node st[MAXN*20];
int rt[MAXN...
阅读全文
才开始学习python,就遇到了编码问题,还好实验室有个python高手,帮我解决了问题,转载它的博文供大家分享!
http://l.ling0322.info/2012/06/python-2x_26.html
如果你 经常遇到这种错误提示的信息: UnicodeEncodeError: ‘ascii’ codec can’t encode characters in position 0-1: ordinal not in range(128), 或者杯具的发现明明在Eclipse中写的程序能够正常运行然后到了终端下面就跳出以上的一段话.
那么, 就证明你和我一样...
阅读全文