Marraco
April 10th, 2008, 10:02 AM
I are coding a generic class that works as red black balanced binary tree. I wanna post it here when finished.
(Is a shame that .NET does not have it predefined, like the array class.)
That data structure will store objects types, to be sure that the user can store his own objects.
My class declare the user object this way:
Public Module Red_Black_Tree
Private Class Node
Public Data As Object 'Each Data to store in this tree
...But I need to force the user to use only Object witch implements the Icomparable interface.
I have two questions:
1-żIs there a way to declare this line Public Data As Object to restrict it only to objects with Icomparable interface (or another workaround).?
2-When the new() subroutine is called, to create a new data, I can Try utilize the Icomparable interface, and if it does not have it, then trow an error (surely the same exception on the Try...End Try block of code), but I would like to have a specific way to check that it implements the Icomparable interface.
(Is a shame that .NET does not have it predefined, like the array class.)
That data structure will store objects types, to be sure that the user can store his own objects.
My class declare the user object this way:
Public Module Red_Black_Tree
Private Class Node
Public Data As Object 'Each Data to store in this tree
...But I need to force the user to use only Object witch implements the Icomparable interface.
I have two questions:
1-żIs there a way to declare this line Public Data As Object to restrict it only to objects with Icomparable interface (or another workaround).?
2-When the new() subroutine is called, to create a new data, I can Try utilize the Icomparable interface, and if it does not have it, then trow an error (surely the same exception on the Try...End Try block of code), but I would like to have a specific way to check that it implements the Icomparable interface.