*In reply to saritr:*I assume you mean a global function not specific to any class.
SystemVerilog does not give you the features necessary to implement randomize() yourself. There is no way to pass constraints as an argument to a function, nor is there a way to interrogate the constraints associated with a class. Function cannot have variable numbers of arguments.