Wide Studio Object Reference

Wide Studio Home
Up to


Class Name

WSClistData

Specification of methods



WSClistData method

Form
WSClistData()
Function
This is the constructor of WSClistData. Creates a instance.
Description
Parameters
Nothing.
Return value
Returns a new instance.
Notice
Samples
   WSClistData  listdata;
   long data1 = 100;
   long data2 = 200;

   //adding 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. Creates a instance which has specified segment size. The segment size is the memory size to add. If you manage a lot of data, add and remove many times, 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, 256 or more, 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 the data into the specified position.
Description
If you do not specify the position or specify -1, it adds the data into bottom of the list. if you specify a position, it pushes(not replace) the data into there.
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 the 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
Nothing.
Notice
If the position is larger than the number:N-1 of the list, it ignores.
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 which the list contains.
Description
Parameters
Nothing.
Return value
Returns the number of data:N.
Notice
Samples
Refer to WSClistData().



getBuf method

Form
void** getBuf()
Function
Returns the data buffer which the list contains.
Description
Parameters
Nothing.
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 the value from the list.
Description
Parameters
(in)void* data the value

Return value
Returns 0 if it suceeded; returns -1 if it failed.
Notice
If several values exit, removes 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 the 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 suceeded; returns -1 if it failed.
Notice
Samples
Refer to del().



clear method

Form
void clear()
Function
Clears the data buffer,
Description
becomes no data is contained.
Parameters
Nothing.
Return value
Nothing.
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 a 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.0

For Use with Wide Studio Release 3.0, Summer 2002


Wide Stuido Home | Up to

Copyright(C) T. Hirabayashi, 1999-2002 Last modified: July 15, 2002