// Generic interface
interface IPoint<T>
{
void MakePoint(T x, T y, T z);
}
// Generic class
class Point<T, N>
{
public T VarT;
public N VarN;
}
// Generic class with constraints
class ConstrainedPoint<T> where T : IPoint<long>
{
public void MakeConstrainedPoint<N>(N x) where N : IPoint<long>
{
}
}
// Class with generic interface
class PointImpl : IPoint<long>
{
public void MakePoint(long x, long y, long z)
{
}
}
|
*> Generic interface
interface-id IPoint using T
method-id makePoint using T (x as T, y as T, z as T).
end method.
end interface.
*> Generic class
class-id Point using T, N.
01 varT T public.
01 varN N public.
end class.
*> Generic class with constraints
class-id ConstrainedPoint using T.
constraints.
constrain T implements type IPoint[binary-double].
method-id makeConstrainedPoint using N (x as N).
constraints.
constrain N implements type IPoint[binary-double].
end method.
end class.
*> Class with generic interface
class-id PointImpl
implements type IPoint[binary-double].
method-id makePoint using T (x as T, y as T, z as T).
end method.
end class.
|
' Generic interface
Interface IPoint(Of T)
Sub MakePoint(x As T, y As T, z As T)
End Interface
' Generic class
Class Point(Of T, N)
public VarT As T
public VarN As N
End Class
' Generic class with constraints
Class ConstrainedPoint(Of T As IPoint(Of Long))
Public Sub MakeConstrainedPoint(Of N As IPoint(Of Long))(x As N)
End Sub
End Class
' Class with generic interface
Class PointImpl
Implements IPoint(Of Long)
Public Sub MakePoint(x As Long, y As Long, z As Long) _
Implements IPoint(Of Long).MakePoint
End Sub
End Class
|