VC中的结构体指针,作为某个函数的参数,或是返回值,在java中如何实现??
VC中自定义结构体,如下:
typedef struct _listElement {
char type;
int start;
int end;
} listElement, *pListElement;
typedef struct _arrayList {
pListElement array;
int size;
int capacity;
} arrayList, *pArrayList;
函数如下:
pListElement listGet(pArrayList list, int idx) {
if (idx >= list->size || idx < 0)
return NULL;
return list->array + idx;
}
这里参数list是结构体指针,返回值类型也为结构体指针。
在java中该如何实现呢??
(我想这个结构体大概可以用类模拟,但是结构体arrayList中的成员pListElement array; 我又该怎么办呢?哎呀,一塌糊涂!!)
请大家指点!谢谢!
是否用ArrayList实现??(队列)