Mutable strings in Java: design, implementation and lightweight text-search algorithms

  • Authors:
  • Paolo Boldi;Sebastiano Vigna

  • Affiliations:
  • Dipartimento di Scienze dell'Informazione, Università degli Studi di Milano, Milano, Italy;Dipartimento di Scienze dell'Informazione, Università degli Studi di Milano, Milano, Italy

  • Venue:
  • Science of Computer Programming - Special issue on principles and practice of programming in java (PPPJ 2003)
  • Year:
  • 2005

Quantified Score

Hi-index 0.00

Visualization

Abstract

The Java string classes, String and StringBuffer, lie at the extremes of a spectrum (immutable, reference based, and mutable, content based). Analogously, available text-search methods on string classes are implemented either as trivial, brute-force double loops, or as very sophisticated and resource-consuming regular-expression search methods. Motivated by our experience in data-intensive text applications, we propose a new string class, MutableString, which tries to get the right balance between extremes in both cases. Mutable strings can be in one of two states, compact and loose, in which they behave more like String and StringBuffer, respectively. Moreover, they support a wide range of sophisticated text-search algorithms with a very low resource usage and set-up time, using a new, very simple randomised data structure (a generalisation of Bloom filters) that stores an approximation from above of a lattice-valued function. Computing the function value requires a constant number of steps, and the error probability can be balanced with space usage. As a result, we obtain practical implementations of Boyer-Moore type algorithms that can be used with very large alphabets, such as Unicode collation elements. The techniques we develop are very general and amenable to a wide range of applications.