Thread: Arraylist methods

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    2

    Arraylist methods

    I have class arraylist with all basic procedures (checkIndex, get, insert, erase nad output).
    In private or protected part i have:
    Code:
    T* element  //1D field that contains elements of list
    int arrayLength  //size of field
    int listSize  //number of elements in list
    I have to add two methods in class:

    • arrayList<T>::removeRange ( remove elements on given interval. Interval has to be passed with inital and final index)
      Example: x=[1,2,3,4,5] //list
      x.removeRange(1,3) //call method
      x=[1,5] //result
    • arrayList<T>::swap(i,j)
      (replace elements on indexes i and j)
      Example: x=[1,2,3,4,5] //list
      x.swap(1,3) //call method
      x=[1,4,3,2,5] //result


    I try to add those two methods but without success
    I don't know what to write in parenthesises beside method, which two variables should I use? Can I just come up with new two of them or have I use already existent?


    I also attached how i try to write one method. I don't know if this is right type of thinking or should i think in different way.
    Every opinion and help is more than wellcome
    Last edited by VirtualAce; 09-15-2008 at 04:48 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Generalising methods to handle multiple weapon types
    By Swarvy in forum Game Programming
    Replies: 2
    Last Post: 05-22-2009, 02:52 AM
  2. ArrayList Basics - Example
    By wbeasl in forum C# Programming
    Replies: 2
    Last Post: 12-26-2008, 04:41 PM
  3. Trouble using ArrayList
    By stevespai in forum C# Programming
    Replies: 12
    Last Post: 07-31-2006, 11:17 AM
  4. Lesson #5 - Methods
    By oval in forum C# Programming
    Replies: 1
    Last Post: 05-04-2006, 03:09 PM
  5. Replies: 8
    Last Post: 07-27-2003, 01:52 PM