Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/adlint/prelude.rb,
lib/adlint/prelude.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#longest_common_substrings_with(rhs) ⇒ Object
DESCRIPTION Finds the longest common substrings in two strings.
- #to_default_external ⇒ Object
Instance Method Details
#longest_common_substrings_with(rhs) ⇒ Object
DESCRIPTION
Finds the longest common substrings in two strings.
Fast and small memory footprint clone detection algorithm developed by Yutaka Yanoh. This algorithm is based on “suffix array with height” data structure.
PARAMETER
- rhs
-
String – A String comparing to the receiver.
RETURN VALUE
Array< SubstringPair > – The longest common substrings.
182 183 184 185 |
# File 'lib/adlint/prelude.rb', line 182 def longest_common_substrings_with(rhs) suffix_array = SuffixArray.new(LeftSuffix.of(self) + RightSuffix.of(rhs)) suffix_array.longest_common_substrings end |
#to_default_external ⇒ Object
73 74 75 |
# File 'lib/adlint/prelude.rb', line 73 def to_default_external encode(Encoding.default_external, :invalid => :replace, :undef => :replace) end |