ht: Tiny Hash Table

Description Usage Arguments Details See Also Examples

View source: R/ht.R

Description

This is a very basic implementation of a hash table using the digest package, primarily for teaching functions and S3 for R programmers.

Usage

1
2
3
4
5
6
7
8
9
ht()

## S3 method for class 'ht'
x[index]

## S3 replacement method for class 'ht'
x[index] <- value

index %in.ht% x

Arguments

x

an ht object

index

A key object

value

A value object

Details

ht is an S3 class that extends environment, and additionally provides [ and [<-. It can use arbitrary R objects as keys and values.

Currently, default options are assummed for digest and hash collisions are not dealt with at all.

See Also

digest

Examples

1
2
3
4
5
6
7
8
 x <- ht()
 x[1] <- 1
 x[1:2] <- 3:4
 x[1]
 x[1:2]
 1:2 %in.ht% x
 mget(ls(x),x)
 if(require(digest)) x[[digest(1:2)]]

nfultz/ht documentation built on May 23, 2019, 4:41 p.m.

Related to ht in nfultz/ht...