算法用于红宝石"字符串#包括&QUOT?; [英] Algorithm used in Ruby for "String#include?"
本文介绍了算法用于红宝石"字符串#包括&QUOT?;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有人能够确定哪些算法用于包括哪些内容?方法在Ruby中?例如
HelloWorld的.INCLUDE?(你好)
解决方案
作为的压花的在他的回答状态,字符串#包括
电话 rb_str_index
。反过来这个函数调用 rb_memsearch
,它实现了拉宾-Karp字符串搜索算法,根据这个帖子对红宝石论坛.COM
。
Is anyone able to pinpoint which algorithm is used for the include? method in Ruby? For example
"helloworld".include?("hello")
解决方案
As emboss states in his answer, String#include
calls rb_str_index
. This function in turn calls rb_memsearch
, which implements the Rabin-Karp string search algorithm, according to this post on ruby-forum.com
.
这篇关于算法用于红宝石"字符串#包括&QUOT?;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文