Skip to content

Scripting msc Github

String Hash Map

This is an implementation of string:string hashmaps in minr.

Example Code (copied from tests())

@using stringHashMap

@define SHashMap testMap = SHashMap()
@player "Setting Test Value"
@var testMap.set("Test Value", "Success!")

@player "Value at Test Value (e: 'Success!'):"
@player {{testMap.get("Test Value")}}
@player "Value at Bad Value (e: null):"
@player {{testMap.get("Bad Value")}}
@player "Value at Bad Value (tryGetDefault) (e: 'Not Found!'):"
@player {{testMap.tryGetDefault("Bad Value", "Not Found!")}}

Classes

Class Description
SHashMap The string hash map object
KeyValuePair A structure that holds associated keys and values
Internal KVPArrayWrapper A structure that holds an array of KeyValuePair

Functions

Function Description
Int hash(String s) Return a hash of a string, from 1 to 997
Int getCharIndex(String char) Get the position of the input character in alphabet
Internal tests() Unit tests for the SHashMap module

Variables

Variable Description
Internal Int arraySize The size of the array used to store the values. Set to 997 as a constant
Internal String alphabet List of all ascii characters, in order