Java Reference
In-Depth Information
/
**
ListADT
*
/
publicinterfaceList<E>{
/
**
Removeallcontentsfromthelist,soitisonceagain
empty.Clientisresponsibleforreclaimingstorage
usedbythelistelements.
*
/
publicvoidclear();
/
**
Insertanelementatthecurrentlocation.Theclient
mustensurethatthelist'scapacityisnotexceeded.
@paramitemTheelementtobeinserted.
*
/
publicvoidinsert(Eitem);
/
**
Appendanelementattheendofthelist.Theclient
mustensurethatthelist'scapacityisnotexceeded.
@paramitemTheelementtobeappended.
*
/
publicvoidappend(Eitem);
/
**
Removeandreturnthecurrentelement.
@returnTheelementthatwasremoved.
*
/
publicEremove();
/
**
Setthecurrentpositiontothestartofthelist
*
/
publicvoidmoveToStart();
/
**
Setthecurrentpositiontotheendofthelist
*
/
publicvoidmoveToEnd();
/
**
Movethecurrentpositiononestepleft.Nochange
ifalreadyatbeginning.
*
/
publicvoidprev();
/
**
Movethecurrentpositiononestepright.Nochange
ifalreadyatend.
*
/
publicvoidnext();
/
**
@returnThenumberofelementsinthelist.
*
/
publicintlength();
/
**
@returnThepositionofthecurrentelement.
*
/
publicintcurrPos();
/
**
Setcurrentposition.
@paramposThepositiontomakecurrent.
*
/
publicvoidmoveToPos(intpos);
/
**
@returnThecurrentelement.
*
/
publicEgetValue();
}
Figure4.1
The ADT for a list.