网站大量收购独家精品文档,联系QQ:2885784924

用c实现vect容器(Using C to achieve the vect container).doc

用c实现vect容器(Using C to achieve the vect container).doc

  1. 1、本文档共19页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
用c实现vect容器(Using C to achieve the vect container)

用c实现vect容器(Using C to achieve the vect container) Using C to achieve Vect, mainly with the pointer and the data length to the incoming data. * * / #ifndef _C_VECTOR_H_ #define _C_VECTOR_H_ //default ELEM #include stdlib.h #include stdio.h #include string.h Typedef struct c_vect{ Unsigned int size; Unsigned int capacity; Char* elem; Int elem_size; }c_vect; C_vect* c_vect_constructor (c_vect* thisptr, int _elemsize); Void c_vect_destructor (c_vect* thisptr); //get the first elem Char* c_vect_first (c_vect* thisptr); Char* c_vect_back (c_vect* thisptr); Char* c_vect_end (c_vect* thisptr); Char* c_vect_begin (c_vect* thisptr); Unsigned long c_vect_size (c_vect* thisptr); //alloc the memory Static void reserve (c_vect* thisptr, int _Capacity); Static _Grow_to (c_vect* thisptr, unsigned int _Count); Static void _Reserve (c_vect* thisptr, int _Count); Void c_vect_push_back (c_vect* thisptr, char* _Val); / / insert an element at a specified location Char* c_vect_insert1 (c_vect* thisptr, char* position, char* _Val); Insert / / a range of elements in a certain position Void c_vect_insert (c_vect* thisptr, char* postion, char* first, char* last); _first _last / / delete the data and returns the next data location Char* c_vect_erase (c_vect* thisptr, char* _First, char *_Last); Void c_vect_clear (c_vect* thisptr); Void c_vect_resize (c_vect* thisptr, unsigned int _Newsize); / / in a range for the two iterator, a number of data Char* c_vect_search_n (c_vect* thisptr, char* _First, char* _Last, int _Count, char* _Val); Char* c_vect_find (c_vect* thisptr, char *_Val); #endif C file #include c_vector.h C_vect* c_vect_constructor (c_vect* thisptr, int _elemsize) { If (thisptr==NULL) { Thisptr= (c_vect*) malloc (sizeof (c_vect)); } If (thisptr) { Thisptr-capacity=0; Thisptr-size=0; Thisptr-elem=NULL; Thisptr-elem_size=_elemsize; } Return thisptr; } Void c_vect_destructor (c_vect* thisptr) { If (thisptr-elem) { Free (thisptr-elem); Thisptr-elem = NULL; } Thisptr-size=0; Thisptr-capac

文档评论(0)

jgx3536 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

版权声明书
用户编号:6111134150000003

1亿VIP精品文档

相关文档