#ifndef LINESEQUENCE_H

#define LINESEQUENCE_H

#include

#include

 

/*****************************************\

***Last Change: 2011-2-22 19:59  Gota  **

** Author: Gota **

**gota DOT july SHIFT2 Google's mail DOT com

** Version: 1.0 **

\*****************************************/

 

/******************************************\

 ******线性表的顺序实现:         *****

 **这里用c语言来实现整个过程,由于c中       *****

 **没有面向对象的概念,所以用一个头文件               ****

 **包含了元素类型的定义、线性表的定义、               ****

 **各种操作方法的定义。如果用c++的话,可以       ****

 **用类将这些封装,用.h文件和.cpp文件实现            ****

 **分离编译,这里的操作可以全部作为成员函             ****

 **数出现,部分不熟悉的库函数可以google               ****

 \*****************************************/

 

/*

*this structure is the type of every element

*you can change it whenever need

*/

struct element{  

int value; /* this is the value to be compared*/

};

 

#define LIST_INIT_SIZE 100 /* this is the size of initialization */

#define LISTINCREMENT 10   /* this is the size of every increment */

 

/*

* this structure is the line_sequence

*/

typedef struct line_sequence{

struct element *elem; /* base address of line_seq */

int length; /* the current length */

int listsize; /*stored number of element */

} *line_seq;

 

/*

*here is the initializ function of line_seq 

*/

int init_line_seq( line_seq line){

line->elem = (element * ) malloc(LIST_INIT_SIZE * sizeof(element));

if(!line->elem ) {

printf("memery error");

exit(1);

}

line->length = 0;

line->listsize = LIST_INIT_SIZE;

return 0; /*"0" means initializ sucessful */

}

 

 

#endif