Archive for the ‘c/c++’ Category.

记录一种删除容器最快办法

for (iterator iter = value.begin(); iter != value.end(); )
{
   if (xxx)
      value.erase(iter++);
   else
      iter++;
}

该方法不适用于vector,原因是官网有一句:

Because vectors use an array as their underlying storage, erasing elements in positions other than the vector endcauses the container to relocate all the elements after the segment erased to their new positions. This is generally an inefficient operation compared to the one performed for the same operation by other kinds of sequence containers (such as list or forward_list).

因此要用下面的方法:

for (iterator iter = value.begin(); iter != value.end(); )
{
   if (xxx)
      iter = value.erase(iter);
   else
      iter++;
}

关于引用

本文通过实际代码描述了C与lua的引用

Continue reading ‘关于引用’ »

C回调lua引用,lua回调C函数

本文根据实际代码介绍c与lua的函数调用。转载请注明出处。

Continue reading ‘C回调lua引用,lua回调C函数’ »

注册全局环境C函数给lua

关于C存储,取得,释放lua的引用

这篇文章详细描述了c怎样存储,取得,释放lua的引用,通过代码一一展现。转载请注明地址。

作者:Jonee

文章出自:http://jonee.net/?p=122

Continue reading ‘关于C存储,取得,释放lua的引用’ »