Lua uses a vector container

Source: Internet
Author: User
1. Compile vector. PKG
Class vector {tolua_template_bind (T, String, ccsprite *) // Add the container type void clear (); int size () Const; const T & operator [] (INT index) const; T & operator [] (INT index); void push_back (T Val); vector ();~ Vector ();};
Ii. Generate the bound file and use the excerpt generated by tolua ++
  ...  #ifdef __cplusplus  tolua_cclass(tolua_S,"vector_CCSprite__","vector<CCSprite*>","",tolua_collect_vector_CCSprite__);  #else  tolua_cclass(tolua_S,"vector_CCSprite__","vector<CCSprite*>","",NULL);  #endif  tolua_beginmodule(tolua_S,"vector_CCSprite__");   tolua_function(tolua_S,"clear",tolua_Lottery_vector_CCSprite___clear00);   tolua_function(tolua_S,"size",tolua_Lottery_vector_CCSprite___size00);   tolua_function(tolua_S,".geti",tolua_Lottery_vector_CCSprite____geti00);   tolua_function(tolua_S,".seti",tolua_Lottery_vector_CCSprite____seti00);   tolua_function(tolua_S,".geti",tolua_Lottery_vector_CCSprite____geti01);   tolua_function(tolua_S,"push_back",tolua_Lottery_vector_CCSprite___push_back00);   tolua_function(tolua_S,"new",tolua_Lottery_vector_CCSprite___new00);   tolua_function(tolua_S,"new_local",tolua_Lottery_vector_CCSprite___new00_local);   tolua_function(tolua_S,".call",tolua_Lottery_vector_CCSprite___new00_local);   tolua_function(tolua_S,"delete",tolua_Lottery_vector_CCSprite___delete00);  tolua_endmodule(tolua_S);  ...
3. Use in Lua
Local string_vector = vector_string _: new_local () string_vector: push_back ("hello") string_vector: push_back ("world") cclog (string_vector [0] .. "".. string_vector [1]) Local ccsprite_vector = vector_ccsprite __: new_local () // note that the pointer type is _ ccsprite_vector: push_back (ccsprite: Create ("image") ccsprite_vector: push_back (ccsprite: Create ("image "))

Lua uses a vector container

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.