views:

61

answers:

2

Ok, so I have a class for a "Advanced Data Structure" (in this case a kinda tree) SO I implimented a Iterator as a private class with in it. So the iterator needs to implement a remove function to remove the last retuirned element.

now my ADT already impliments a remove function, and in this case there is very little (thinking about it, i think nothing) to be gain by implimenting a different remove function for the iterator.

so how do I go about calling the remove from my ADT

sketch of my struture:

public class ADT {
...
   private class ADT_Iterator impliments  java.util.Itorator{
      ...
      public void remove(){
          //where I want to call the ADT's remove function from
      }
...

    public void remove( Object paramFoo )
    {
     ...
    }

    ...     

}

So just calling remove(FooInstance) won't work (will it?) and this.remove(FooInstance) is the same thing.

what do i call? (and changign the name of the ADT's remove function is not an option, as that AD T has to meet an Interace wich I am note at liberty to change)

I could make both of them call a removeHelper functon, I guess...

+4  A: 
ADT.this.remove(object)

(Though just calling remove(object) will work in this case since it has a different signature than the remove() method in the iterator.)

bkail
+3  A: 

To get the reference for the outer class which the inner class is "attached" use ClassName.this, in your case:

   private class ADT_Iterator impliments  java.util.Itorator{
      ...
      public void remove(){
          ADT.this.remove(obj)
      }
Felipe Cypriano