hyper-v에서 centOS 설치

http://warmz.tistory.com/927


mySQL 설치

http://jmnote.com/wiki/CentOS_5%EC%97%90_MySQL_5.5_%EC%84%A4%EC%B9%98_(yum)


nodejs+express 설치

http://seraphmate.tistory.com/100

왜인지는 모르겠는데 CentOS에서 

npm -g install express를 하고나서 설치가 제대로 끝났는데

express abc 를 해도 

bash : express : command not found 가 나온다.


이럴때는 

sudo npm install -g express@2.5.8

요로코롬 하면 되더라.


http://www.sitepoint.com/forums/showthread.php?938814-Cannot-use-Express-after-installing-globally-OS-X-10-8-Mountain-Lion


요기서 찾음


나처럼 고생하지않길..

출처 : http://gamepro.tistory.com/263

///////////////////////////////////////////////////////

for( Iterator= Vector.begin(); Iterator != Vector.end();)

{

Vector.erase(Iterator);

}

///////////////////////////////////////////////////////

for( Iterator = List.begin(); Iterator != List.end(); )

{

List.erase(Iterator);

}

위 두 문장의 차이가 뭘까?

위의 문장에서는 문제가 없지만 아래 문장에서는 에러가 발생한다.

왜 그럴까? erase 함수의 구현은 둘다 똑같은데...

그 이유는....

RandomAccessIterator와 BidirectionalIterator의 차이에 있다.

vector는 해당 원소가 삭제되면 Iterator의 공백을 삭제된 원소다음에 있는 원소 위치로 채워지게 된다. 이는 RandomAccessIterator(멋대로 접근 가능 지시자)라 가능한 듯...(솔직히 컴파일러에 따라 다른지 그것까지는 모르겠음. 일단 Visual Studio에서는 그렇게 작동)

허나 list는 BidirectionalIterator(순서대로 차근차근 접근 가능)이므로 해당 원소가 삭제되면 Iterator는 그 다음 위치를 잃어버리게 되는 것이다. 결국 그 다음 지시자의 위치는 까마득한 별나라로...

이를 위한 해결 방법

가장 확실한 방법은 erase 함수의 리턴값을 이용하는 것이다.

erase 함수의 리턴값이 바로 삭제 원소 다음에 있는 원소 iterator이기 때문...

for( Iterator = List.begin(); Iterator != List.end(); )

{

Iterator = List.erase(Iterator);

}

뭐 굳이 ++을 쓰고 싶다면...

for( Iterator = List.begin(); Iterator != List.end(); )

{

List.erase(Iterator++);

}

이런 식으로 사용하면 된다. 허나....

for( Iterator = List.begin(); Iterator != List.end(); Iterator++)

{

List.erase(Iterator);

}

이런 식의 사용은 오류를 초래... 위에 설명했다시피 Iterator는 erase 함수를 거쳐 이미 갈 곳을 잃었기 때문에 Iterator++ 이란 문장은 엄한 곳만 가리키기게 되는 꼴....

CString CFileDisperserDlg::GetFileSize(int size)

{

//HANDLE hFile= CreateFile((CString)Path,GENERIC_READ,0,NULL,OPEN_EXISTING,0,NULL);

//int size = ::GetFileSize(hFile,NULL);

CString strByte,strFileSize;


if(size > 1024)

{

size /= 1024;

strByte = _T("KB");

}

if(size > 1024)

{

size /= 1024;

strByte = _T("MB");

}

if(size > 1024)

{

size /= 1024;

strByte = _T("GB");

}


strFileSize.Format(_T("%d %s"),size,strByte);

return strFileSize;

}

Parameter : filePath

return value : fileName


CString CFileDisperserDlg::GetFileName(CString filePath)

{

CString strResult;

filePath.Replace(_T("/"), _T("\\"));


int nPos = filePath.ReverseFind(_T('\\'));

if(nPos != -1)

{

strResult = filePath.Mid(nPos + 1);

}

else

{

strResult = filePath;

}


return strResult;

}

원하던 랜덤함수는 짧은시간내에도 다른 값을 뱉어내는 함수를 원했는데... 요함수는 서버랑 싱크를 맞출때 쓰는 함수인것같다..

C에서

#define W 32

#define R 16

#define P 0

#define M1 13

#define M2 9

#define M3 5


#define MAT0POS(t,v) (v^(v>>t))

#define MAT0NEG(t,v) (v^(v<<(-(t))))

#define MAT3NEG(t,v) (v<<(-(t)))

#define MAT4NEG(t,b,v) (v ^ ((v<<(-(t))) & b))


#define V0            STATE[state_i                   ]

#define VM1           STATE[(state_i+M1) & 0x0000000fU]

#define VM2           STATE[(state_i+M2) & 0x0000000fU]

#define VM3           STATE[(state_i+M3) & 0x0000000fU]

#define VRm1          STATE[(state_i+15) & 0x0000000fU]

#define VRm2          STATE[(state_i+14) & 0x0000000fU]

#define newV0         STATE[(state_i+15) & 0x0000000fU]

#define newV1         STATE[state_i                   ]

#define newVRm1       STATE[(state_i+14) & 0x0000000fU]


#define FACT 2.32830643653869628906e-10


static unsigned int state_i = 0;

static unsigned int STATE[R];

static unsigned int z0, z1, z2;


void InitWELLRNG512a (unsigned int *init){

   int j;

   state_i = 0;

   for (j = 0; j < R; j++)

     STATE[j] = init[j];

}


double WELLRNG512a (void){

  z0    = VRm1;

  z1    = MAT0NEG (-16,V0)    ^ MAT0NEG (-15, VM1);

  z2    = MAT0POS (11, VM2)  ;

  newV1 = z1                  ^ z2; 

  newV0 = MAT0NEG (-2,z0)     ^ MAT0NEG(-18,z1)    ^ MAT3NEG(-28,z2) ^ MAT4NEG(-5,0xda442d24U,newV1) ;

  state_i = (state_i + 15) & 0x0000000fU;

  return ((double) STATE[state_i]) * FACT;

}



C++에서

class Well512Random

{


protected:

unsigned int state[16];

    unsigned int index;    


public:


    Well512Random(unsigned int nSeed)

    {

index = 0;

unsigned int s = nSeed;

        for (int i = 0; i < 16; i++)

        {

            state[i] = s;

s += s + 73;

        }

    }


    unsigned int Next(int minValue, int maxValue)

    {

        return (unsigned int)((Next() % (maxValue - minValue)) + minValue);

    }


    unsigned int Next(unsigned int maxValue)

    {

        return Next() % maxValue;

    }


    unsigned int Next()

    {

        unsigned int a, b, c, d;


        a = state[index];

        c = state[(index + 13) & 15];

        b = a ^ c ^ (a << 16) ^ (c << 15);

        c = state[(index + 9) & 15];

        c ^= (c >> 11);

        a = state[index] = b ^ c;

        d = a ^ ((a << 5) & 0xda442d24U);

        index = (index + 15) & 15;

        a = state[index];

        state[index] = a ^ b ^ d ^ (a << 2) ^ (b << 18) ^ (c << 28);


        return state[index];

    }

};


C#에서


public class Well512Random

{

    uint[] state = new uint[16];

    uint index = 0;


    public Well512Random(uint nSeed)

    {

uint s = nSeed;

        for (int i = 0; i < 16; i++)

        {

            state[i] = s;

s += s + 73;

        }

    }


    internal uint Next(int minValue, int maxValue)

    {

        return (uint)((Next() % (maxValue - minValue)) + minValue);

    }


    public uint Next(uint maxValue)

    {

        return Next() % maxValue;

    }


    public uint Next()

    {

        uint a, b, c, d;


        a = state[index];

        c = state[(index + 13) & 15];

        b = a ^ c ^ (a << 16) ^ (c << 15);

        c = state[(index + 9) & 15];

        c ^= (c >> 11);

        a = state[index] = b ^ c;

        d = a ^ ((a << 5) & 0xda442d24U);

        index = (index + 15) & 15;

        a = state[index];

        state[index] = a ^ b ^ d ^ (a << 2) ^ (b << 18) ^ (c << 28);

        return state[index];

    }

}



+ Recent posts