 | | Wide Studio Object Reference
| |
Class Name
WSClistData
Specification of methods
WSClistData method
- Form
- WSClistData()
- Function
- This is the constructor of WSClistData.
Creates an instance.
- Description
-
- Parameters
- None.
- Return value
- Returns a new instance.
- Notice
-
- Samples
-
WSClistData listdata;
long data1 = 100;
long data2 = 200;
//add data.
listdata.add((void*)data1);
listdata.add((void*)data2);
//get the data.
long d1 = (long)listdata[0];
long d2 = (long)listdata[1];
//replace data.
long data3 = 300;
long data4 = 400;
listdata.setData(0,(void*)data3);
listdata.setData(1,(void*)data4);
//get data with getData()
long d1 = (long)listdata.getData(0);
long d2 = (long)listdata.getData(1);
//get the number of data.
long num = listdata.getNum();
//delete data.
listdata.del((void*)400);
//delete data with position.
listdata.delPos(0);
//clear all data.
listdata.clear();
WSClistData method
- Form
- WSClistData(long segment_size)
- Function
- This is the constructor of WSClistData.
It creates an instance which has a specified segment size.
The segment size is the memory size to add.
If you manage a lot of data, or add and remove data many times,
a large size is better.
The default is 16, which can contain 16 pointers.
- Description
-
- Parameters
-
(in)long segment_size | the segment size |
- Return value
- Returns a new instance.
- Notice
- If specified, the size is minus. If it is 256 or more, it adjusts to 255.
- Samples
-
//buffer unit size is 64
//expand internal buffer each 64 unit.
WSClistData indexdata(64);
add method
- Form
- long add(void* data,long pos = -1)
- Function
- Adds data into the specified position.
- Description
- If you do not specify the position or specify -1,
it adds the data to the bottom of the list.
If you specify a position,
it pushes (not overwrites) the data into that location.
- Parameters
-
(in)void* data | the data |
(in)long pos | the position to add(top: 0,..,N,-1: bottom |
- Return value
- 0
- Notice
- If the position is larger than the number: N of the list,
it adds the data to the bottom.
- Samples
- Refer to WSClistData().
setData method
- Form
- void setData(long pos,void* data)
- Function
- Replaces data of the specified position.
- Description
-
- Parameters
-
(in)long pos | |
(in)long pos | the position to replace(top: 0,..,N-1,-1: bottom |
(in)void* data | the data |
- Return value
- None.
- Notice
- If the position is larger than the number: N-1 of the list,
it ignores it.
- Samples
- Refer to WSClistData().
getData method
- Form
- void* getData(long pos)
- Function
- Returns the value of the specified position.
- Description
-
- Parameters
-
(in)long pos | the position to replace(top: 0,..,N-1,-1: bottom |
- Return value
- Returns the value.
- Notice
- If the position is larger than the number: N-1 of the list,
it returns NULL.
- Samples
- Refer to WSClistData().
getNum method
- Form
- long getNum()
- Function
- Returns the number of data that the list contains.
- Description
-
- Parameters
- None.
- Return value
- Returns the number of data: N.
- Notice
-
- Samples
- Refer to WSClistData().
getBuf method
- Form
- void** getBuf()
- Function
- Returns the data buffer that the list contains.
- Description
-
- Parameters
- None.
- Return value
- Returns the data buffer.
- Notice
- Do not delete the return value.
- Samples
-
WSClistData listdata;
long data1 = 100;
long data2 = 200;
long data3 = 300;
//add data.
listdata.add((void*)data1);
listdata.add((void*)data2);
listdata.add((void*)data3);
//get the internal buffer.
void** ptr = listdata.getBuf();
//get data from the buffer.
long d1 = *(long*)(ptr[0]); //data1: 100
long d2 = *(long*)(ptr[1]); //data2: 200
long d3 = *(long*)(ptr[2]); //data3: 300
del method
- Form
- long del(void*)
- Function
- Removes a value from the list.
- Description
-
- Parameters
-
- Return value
- Returns 0 if it succeeds; returns -1 if it fails.
- Notice
- If several values exist, it removes the first one.
- Samples
-
WSClistData listdata;
long data1 = 100;
long data2 = 200;
long data3 = 300;
//add data.
listdata.add((void*)data1);
listdata.add((void*)data2);
listdata.add((void*)data3);
//delete data.
listdata.del((void*)200);
//delete data with position.
listdata.delPos(1);
//clear all data.
listdata.clear();
delPos method
- Form
- long delPos(long pos)
- Function
- Removes data of the specified position.
- Description
- Removes the bottom one, if specified -1.
- Parameters
-
(in)long pos | the position (top:0,..,N-1,-1: bottom) |
- Return value
- Returns 0 if it succeeds; returns -1 if it fails.
- Notice
-
- Samples
- Refer to del().
clear method
- Form
- void clear()
- Function
- Clears the data buffer, such that
- Description
- no data is contained.
- Parameters
- None.
- Return value
- None.
- Notice
-
- Samples
- Refer to del().
= operator
- Form
- WSClistData & operator = (WSClistData &)
- Function
- Copies the list.
- Description
-
- Parameters
-
(in)WSClistData & src | the list of source |
- Return value
-
- Notice
-
- Samples
-
WSClistData listdata;
long data1 = 100;
long data2 = 200;
long data3 = 300;
//copy the list.
WSClistData listdata2;
listdata2 = listdata;
[] operator
- Form
- void* & operator[](long pos)
- Function
- Return the data of the specified position.
It seems like the elements of an array.
- Description
-
- Parameters
-
(in)long pos | the position(top: 0,..,N-1) |
- Return value
- Return the data.
- Notice
- For example:
- Samples
-
WSClistData list();
list.add( (void*)100 );
list.add( (void*)200 );
:
void* d0 = list[0]; //same as list.getData(0)
void* d1 = list[1]; //same as list.getData(1)
Document Release 3.20 For use with Wide Studio Release 3.20, Spring 2003 Wide Studio Home | Up to Copyright(C) T. Hirabayashi, 1999-2003 | | Last modified: February 3, 2003 | |