The native implementations are mentioned in this post, which might be helpful in writing your custom implementation.