Aditya Sirohi wrote:So the above code that i pasted is correct?
The only way we could answer that question with any degree of certainty would be to compile, run, and
test it - which is something YOU can do yourself, right? I would assume you already have it in a full working program. For one of us to test it, we'd have to write a bunch of code to drop this method into, which most people don't have the time to do.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors