<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0">
<channel>
<title>나이드의 블로그</title>
<link>http://naid01.nawow.net/index.php</link>
<description>잡다한 블로그</description>
<language>ko</language>
<pubDate>Mon,  6 Nov 2006 12:57:28 +0900</pubDate>
<item>
<title>Mutex &amp; CriticalSection</title>
<link>http://naid01.nawow.net/index.php?pl=8</link>
<description><![CDATA[ 뮤텍스와 세마포어의 경우 콘솔 레벨에서 동기화를 하므로,<br />
보다 포괄적이지만 그만큼 연산이 느리다는 단점이 있다.<br />
따라서 프로세스 레벨에서 동기화 시키는 크리티컬 섹션이<br />
보다 연산이 빠르기 때문에 게임에는 주로 이용된다.<br />
뭔가 있어 보이지만 사용은 무척 쉽다;<br />
<br />
**뮤텍스<br />
<br />
void MutexExample()<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;static HANDLE _mutex;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// Mutex생성<br />
&nbsp;&nbsp;&nbsp;&nbsp;if( _mutex== NULL )<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// 초기화<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_mutex= CreateMutex(NULL, FALSE, "test");<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// 락<br />
&nbsp;&nbsp;&nbsp;&nbsp;WaitForSingleObject( _mutex, INFINITE );<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// 코드 //<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// 언락<br />
&nbsp;&nbsp;&nbsp;&nbsp;ReleaseMutex(_mutex);<br />
}<br />
<br />
**크리티컬 섹션<br />
<br />
// 함수 선언<br />
class CriticalSectionExample<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;void Init();<br />
&nbsp;&nbsp;&nbsp;&nbsp;void Uninit();<br />
&nbsp;&nbsp;&nbsp;&nbsp;void Update();<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// 멤버 변수<br />
&nbsp;&nbsp;&nbsp;&nbsp;CRITICAL_SECTION _critsec;<br />
}<br />
<br />
void CriticalSectionExample::Init()<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;// 초기화 함수<br />
&nbsp;&nbsp;&nbsp;&nbsp;InitializeCriticalSection( &_critsec );<br />
}<br />
<br />
void CriticalSectionExample::Uninit()<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;// 종료 함수<br />
&nbsp;&nbsp;&nbsp;&nbsp;DeleteCriticalSection( &_critsec );<br />
}<br />
<br />
void CriticalSectionExample::Update()<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;// 락<br />
&nbsp;&nbsp;&nbsp;&nbsp;EnterCriticalSection( &_critsec );<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;// 코드 //<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;//언락<br />
&nbsp;&nbsp;&nbsp;&nbsp;LeaveCriticalSection( &_critsec );<br />
}]]></description>
<category>프로그래밍</category>
<author>Naid</author>
<pubDate>Fri, 11 Aug 2006 15:13:14 +0900</pubDate>
</item>
<item>
<title>Cloud Rendering</title>
<link>http://naid01.nawow.net/index.php?pl=6</link>
<description><![CDATA[ 
<iframe border=1 marginWidth=0 marginHeight=0  src="http://naid01.nawow.net/article/004/004.htm"  frameBorder=0  scrolling=no  height = 1400 width = 500 = topmargin="0" leftmargin="0"></iframe>
]]></description>
<category>그래픽스</category>
<author>Naid</author>
<pubDate>Tue, 28 Feb 2006 21:35:24 +0900</pubDate>
</item>
<item>
<title>STL 정리</title>
<link>http://naid01.nawow.net/index.php?pl=5</link>
<description><![CDATA[ <font color="#FF0000"><b>o STL history</b></font><br />
 - Alexander Spepanov, late 70s, <<<Generic Algorithm>>><br />
 - 1985, generic Ada library<br />
 - 1987, C++ was premature<br />
 - 1988~1992, HP algorithm project<br />
 - 1994, STL was adopted into the draft standard ANSI/ISO C++<br />
<br />
<br />
<font color="#FF0000"><b>o C++ for STL</b></font><br />
 - Nice Classes( HP & Andrew Koenig from the Bell Labs)<br />
&nbsp;&nbsp;. Copy constructor : T (const T&)<br />
&nbsp;&nbsp;. Assignment operator : T& operator= (const T&)<br />
&nbsp;&nbsp;. Equality operator : int operator== (const T&, const T&)<br />
&nbsp;&nbsp;. Inequality operator : int operator!= (const T&, const T&)<br />
 - Function objects : operator()<br />
 - Function Templates<br />
<font color="#008000">&nbsp;&nbsp;template <class T><br />
&nbsp;&nbsp;void swap (T& a, T& b)<br />
&nbsp;&nbsp;  T tmp = a;<br />
&nbsp;&nbsp;  a = b;<br />
&nbsp;&nbsp;  b = tmp;<br />
&nbsp;&nbsp;}</font><br />
 - Class Templates <br />
<font color="#008000">&nbsp;&nbsp;template <class T><br />
&nbsp;&nbsp;class vector {<br />
&nbsp;&nbsp;  T* v;<br />
&nbsp;&nbsp;  int sz;<br />
&nbsp;&nbsp;public :<br />
&nbsp;&nbsp;  vector (int s) { v= new T[sz=s]; }<br />
&nbsp;&nbsp;  ~vector () { delete [] v; }<br />
&nbsp;&nbsp;  T& operator[] (int i) { return v[i]; }<br />
&nbsp;&nbsp;  int get_size() { return sz; }<br />
&nbsp;&nbsp;};</font><br />
<br />
<br />
<font color="#FF0000"><b>o A STL overview</b></font><br />
 - STL is a component library.<br />
  . Algorithm : computational procedure that is able to work on different containers<br />
  . Container : object that is able to keep and administer objects<br />
  . Iterator : abstraction of the algorithm-access to containers so that an algorithm is able to work on different containers<br />
  . Function Object : a class that has the function-call operator (operator() ) defined<br />
  . Adaptor : encapsulates a component to provide another interface (e.g. make a stack out of a list)<br />
<br />
<br />
<font color="#FF0000"><b>o Containers</b></font><br />
 - Sequence Containers<br />
  . Vector<br />
  . Deque<br />
  . List<br />
 - Associative Containers<br />
  . Set<br />
  . Multiset<br />
  . Map<br />
  . Multimap<br />
<br />
<br />
<font color="#FF0000"><b>o Iterators</b></font> - a generalization of pointers<br />
 - operator*<br />
 - operator++<br />
 - Sample Iterator<br />
<font color="#008000">  vector<int> v(3);<br />
  <br />
  v[0] = 5;<br />
  v[1] = 2;<br />
  v[2] = 7;<br />
  <br />
  vector<int>::iterator first = v.begin();<br />
  vector<int>::iterator last = v.end();<br />
  <br />
  while (first != last)<br />
&nbsp;&nbsp;cout << *first++ << " ";<br />
&nbsp;&nbsp;</font><br />
 - sort(v.begin(), v.end() );<br />
 - Input Iterators and Output Iterators for single pass algorithms<br />
 - Forward Iterators for multi-pass one-directional algorithms<br />
 - Bidirectional Iterators for multi-pass algorithms<br />
 - Random Access Iterators for random access algorithms<br />
<br />
<br />
<font color="#FF0000"><b>o Algorithms</b></font><br />
 - algorithm example : binary search<br />
 - Step 0 : Initial Step<br />
<font color="#008000">  const int* binary_search (const int* array, int n, int x) {<br />
&nbsp;&nbsp;const int* lo = array, *hi = array + n, *mid;<br />
&nbsp;&nbsp;while(lo != hi) {<br />
&nbsp;&nbsp; mid = lo + (hi - lo) / 2;<br />
&nbsp;&nbsp; if (x == *mid) return mid;<br />
&nbsp;&nbsp; if (x < *mid) hi = mid; else lo = mid + 1;<br />
&nbsp;&nbsp;}<br />
&nbsp;&nbsp;return 0;<br />
  }</font><br />
 - Step 1 : Templates<br />
<font color="#008000">  template<class T><br />
  const T* binary_search (const T* array, int n, const T& x) {<br />
&nbsp;&nbsp;const T* lo = array, *hi = array + n, *mid;<br />
&nbsp;&nbsp;while(lo != hi) {<br />
&nbsp;&nbsp; mid = lo + (hi - lo) / 2;<br />
&nbsp;&nbsp; if (x == *mid) return mid;<br />
&nbsp;&nbsp; if (x < *mid) hi = mid; else lo = mid + 1;<br />
&nbsp;&nbsp;}<br />
&nbsp;&nbsp;return 0;<br />
  }</font><br />
 - Step 2 : Null Pointer<br />
<font color="#008000">  template<class T><br />
  const T* binary_search (const T* array, int n, const T& x) {<br />
&nbsp;&nbsp;const T* lo = array, *hi = array + n, *mid;<br />
&nbsp;&nbsp;while(lo != hi) {<br />
&nbsp;&nbsp; mid = lo + (hi - lo) / 2;<br />
&nbsp;&nbsp; if (x == *mid) return mid;<br />
&nbsp;&nbsp; if (x < *mid) hi = mid; else lo = mid + 1;<br />
&nbsp;&nbsp;}<br />
&nbsp;&nbsp;return array + n;<br />
  }</font><br />
 - Step 3 : Iterator<br />
<font color="#008000">  template<class T><br />
  const T* binary_search (T* first, T* last, const T& value) {<br />
&nbsp;&nbsp;const T* lo = array, *hi = array + n, *mid;<br />
&nbsp;&nbsp;while(lo != hi) {<br />
&nbsp;&nbsp; mid = lo + (hi - lo) / 2;<br />
&nbsp;&nbsp; if (value == *mid) return mid;<br />
&nbsp;&nbsp; if (value < *mid) hi = mid; else lo = mid + 1;<br />
&nbsp;&nbsp;}<br />
&nbsp;&nbsp;return last;<br />
  } </font><br />
 - Step 4 : No more pointers but iterators<br />
<font color="#008000">  template<class RandomAccessIterator, class T><br />
  RandomAccessIterator binary_search (RandomAccessIterator first,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  RandomAccessIterator last,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  const T& value) {<br />
&nbsp;&nbsp;RandomAccessIterator not_found = last, mid;<br />
&nbsp;&nbsp;while(first != last) {<br />
&nbsp;&nbsp; mid = first + (last - first) / 2;<br />
&nbsp;&nbsp; if (value == *mid) return mid;<br />
&nbsp;&nbsp; if (value < *mid) last = mid; else first = mid + 1;<br />
&nbsp;&nbsp;}<br />
&nbsp;&nbsp;return not_found;<br />
  }</font><br />
 <br />
<br />
<font color="#FF0000"><b>o Fuction Objects</b></font><br />
 - unary_function<br />
<font color="#008000">  template <class Arg, class Result><br />
  struct unary_function {<br />
&nbsp;&nbsp;typedef Arg argument_type;<br />
&nbsp;&nbsp;typedef Result result_type;<br />
  };</font><br />
 - unary function object example<br />
<font color="#008000">  template <class T><br />
  struct negate : unary_function {<br />
&nbsp;&nbsp;T operator()(const T& x) const { return -x; }<br />
  };</font><br />
 - binary_function<br />
<font color="#008000">  template <class Arg1, class Arg2, class Result><br />
  struct binary_function {<br />
&nbsp;&nbsp;typedef Arg1 first_argument_type;<br />
&nbsp;&nbsp;typedef Arg2 second_argument_type;<br />
&nbsp;&nbsp;typedef Result result_type;<br />
  };</font><br />
 - binary function object example<br />
<font color="#008000">  template <class T><br />
  struct logical_and : binary_function<T, T, bool> {<br />
&nbsp;&nbsp;bool operator()(const T& x, const T& y) const { return x && y; }<br />
  };</font><br />
<br />
<b><font color="#FF0000">o Adaptors</font></b> - template classes that provides interface mappings<br />
 - Container Adaptors<br />
  . A stack from a vector, a list or a deque.<br />
  . A queue from a list or a deque.<br />
  . A priority queue from a vector or a deque.<br />
 - Iterator Adaptors<br />
  . Reverse Iterators<br />
  . Insert Iterators<br />
  . Raw Storage Iterator<br />
 - Function Adaptors<br />
  . Negators<br />
  . Binders<br />
  . Adaptors for pointers to functions<br />
 <br />
<br />
<b><font color="#FF0000">o Allocators and memory handling</font></b><br />
 - Objects that encapsulate following information<br />
 · pointer types<br />
 · type of their difference (difference type ptrdiff_t)<br />
 · type of the size of objects in a memory model (size type size_t)<br />
 · memory allocation and deallocation primitives.]]></description>
<category>프로그래밍</category>
<author>Naid</author>
<pubDate>Tue, 14 Feb 2006 10:47:33 +0900</pubDate>
</item>
<item>
<title>QEM의 구현</title>
<link>http://naid01.nawow.net/index.php?pl=4</link>
<description><![CDATA[ 
<iframe border=1 marginWidth=0 marginHeight=0  src="http://naid01.nawow.net/article/003/003.htm"  frameBorder=0  scrolling=no  height = 1700 width = 500 = topmargin="0" leftmargin="0"></iframe>
<br />
<table align=left><tr><td style=padding-right:5><center><table class=ib onclick="location.href='http://naid01.nawow.net/down.php?attachname=384440.zip'"><tr><td><img src=http://naid01.nawow.net/images/icon/zip.gif></td><td class=cap1>qslim-2_0.zip (452.0 KB)</td></tr></table></center></td></tr><tr><td class=cap1> </td></tr></table>]]></description>
<category>그래픽스</category>
<author>Naid</author>
<pubDate>Fri, 27 Jan 2006 15:57:24 +0900</pubDate>
</item>
<item>
<title>Progressive Mesh의 구현</title>
<link>http://naid01.nawow.net/index.php?pl=3</link>
<description><![CDATA[ 
<iframe border=1 marginWidth=0 marginHeight=0  src="http://naid01.nawow.net/article/002/002.htm"  frameBorder=0  scrolling=no  height = 3400 width = 500 = topmargin="0" leftmargin="0"></iframe>
<table align=left><tr><td style=padding-right:5><center><table class=ib onclick="location.href='http://naid01.nawow.net/down.php?attachname=682649.zip'"><tr><td><img src=http://naid01.nawow.net/images/icon/zip.gif></td><td class=cap1>Progressive.zip (3.06 MB)</td></tr></table></center></td></tr><tr><td class=cap1> </td></tr></table>]]></description>
<category>그래픽스</category>
<author>Naid</author>
<pubDate>Tue, 24 Jan 2006 18:06:26 +0900</pubDate>
</item>
</channel>
</rss>
