Ruby中用于“String #include?”的算法

前端之家收集整理的这篇文章主要介绍了Ruby中用于“String #include?”的算法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
有人能够确定哪个算法用于包含? Ruby中的方法?例如
"helloworld".include?("hello")

解决方法

作为emboss在他的回答中陈述,String#include调用rb_str_index.根据ruby-forum.com上的 this post,该函数依次调用实现 Rabin-Karp string search algorithm的rb_memsearch.
原文链接:https://www.f2er.com/ruby/271160.html

猜你在找的Ruby相关文章