001package edu.wpi.first.wpilibj.networktables2.util; 002 003/** 004 * An unsynchronized map which maps characters to objects. This map is backed by a array and will only perform well the values are consecutive starting at 0 005 * 006 * @author Mitchell 007 * 008 */ 009public class CharacterArrayMap extends ResizeableArrayObject{ 010 /** 011 * Put a value with the given key 012 * @param key 013 * @param value 014 */ 015 public void put(final char key, final Object value){ 016 ensureSize(key+1); 017 array[key] = value; 018 } 019 020 /** 021 * @param key 022 * @return the value associated with the given key or null if there is no value 023 */ 024 public Object get(final char key){ 025 if(key>=array.length) 026 return null; 027 return array[key]; 028 } 029 030 /** 031 * clear all values 032 */ 033 public void clear() { 034 for(int i = 0; i<array.length; ++i) 035 array[i] = null; 036 } 037 038 /** 039 * Remove the value for the given key 040 * @param key 041 */ 042 public void remove(final char key) { 043 if(key>=array.length) 044 return; 045 array[key] = null; 046 } 047}