StringSet: Create a StringSet object.

View source: R/stree.S

StringSetR Documentation

Create a StringSet object.

Description

This is a concstructor for the internal C-level String Set data structure. This can be thought of as an unordered character vector with a length and facilities for indexing.

Since a string set is a set, the order of the elements is not meaningful. However the indexing facilities can be useful, for example, when sampling where the order is not important, but consistent across calls.

Usage

StringSet(..., class = "StringSet", .els = as.character(unlist(list(...))))

Arguments

...

one or more character vectors. These are are combined into one large character vector to be used to construct the set. This allows one to make calls like StringSet(x, y). Of course, this is just a convenience for StringSet(c(x, y)) - 3 more characters.

class

the name of the class of which we want an instance. Being able to specify this allows the caller to use this function as a constructor for derived classes.

.els

a character vector giving the elements for the set. This is a more convenient form than ... if the values are already in a vector.

Details

This creates an object in C from the libstree library and returns a reference to it.

Value

An object of class StringSet-class.

Author(s)

Duncan Temple Lang <duncan@wald.ucdavis.edu>

References

http://www.cl.cam.ac.uk/~cpk25/libstree/libstree http://www.omegahat.org/Rlibstree

See Also

SuffixTree-methods StringSet-class getLongestSubstring

Examples

words = c("stemming", "boing", "springs")
set = StringSet(words)

length(set)

set[sample(1:3, 1)]


 # Appending values to the set 
 # Note that we don't have to re-assign the value.
append(set, c("a", "b", "c"))

length(set)


lapply(set, function(x) x)
sapply(set, function(x) x)

sapply(set, getNativeSymbolInfo("R_LST_elementAsRString"))


omegahat/Rlibstree documentation built on Jan. 17, 2024, 6:37 p.m.