LongestPrefixMatch
This class stores data belonging to decimal number ranges. This can be used inside dial plans. Ranges with more than 2 permutations are compressed automatically. When querying this the value of the longest matching path will be returned. So if there are the ranges 1 and 11-13 when querying with 12, the later's value will be returned. This is as it holds the longer prefix (2 digits instead of 1).
Example usage:
val lpm = new LongestPrefixMatch[String].
addValueForRange("123", "456", "V1").
addValueForRange("12345", "12349", "V2")
lpm.getValueFromPrefix("1234") // will return Some("V1")
lpm.getValueFromPrefix("12347") // will return Some("V2")
Value members
Constructors
Concrete methods
Adds a range-specific value. The rangeStart and rangeEnd parameters must be of the same length.
Adds a range-specific value. The rangeStart and rangeEnd parameters must be of the same length.
- Value parameters:
- rangeEnd
the inclusive end of the range
- rangeStart
the inclusive start of the range
- value
the data to be stored for this range
- Returns:
an updated instance of [this]
Removes a range-specific value. The rangeStart and rangeEnd parameters must be of the same length.
Removes a range-specific value. The rangeStart and rangeEnd parameters must be of the same length.
- Value parameters:
- rangeEnd
the inclusive end of the range
- rangeStart
the inclusive start of the range
- Returns:
an updated instance of [this]