Hello.
If you are able to do then you can have a look at the source code of the add() and remove() methods to see the logic they have used.
The source code shall be available as a zip file in...