From 3ab855e69ab3e99128bce58fd236a1f9032f8d3b Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Sun, 28 Apr 2013 15:13:51 -0400 Subject: [PATCH] add hasKey() methods --- core/src/processing/data/FloatDict.java | 5 +++++ core/src/processing/data/IntDict.java | 5 +++++ core/src/processing/data/StringDict.java | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/core/src/processing/data/FloatDict.java b/core/src/processing/data/FloatDict.java index f23c8f981..5167cf35c 100644 --- a/core/src/processing/data/FloatDict.java +++ b/core/src/processing/data/FloatDict.java @@ -246,6 +246,11 @@ public class FloatDict { } + public boolean hasKey(String key) { + return index(key) != -1; + } + + // /** Increase the value of a specific key by 1. */ // public void inc(String key) { // inc(key, 1); diff --git a/core/src/processing/data/IntDict.java b/core/src/processing/data/IntDict.java index 18c95aea2..dfa079980 100644 --- a/core/src/processing/data/IntDict.java +++ b/core/src/processing/data/IntDict.java @@ -235,6 +235,11 @@ public class IntDict { } + public boolean hasKey(String key) { + return index(key) != -1; + } + + /** Increase the value of a specific key by 1. */ public void increment(String key) { add(key, 1); diff --git a/core/src/processing/data/StringDict.java b/core/src/processing/data/StringDict.java index c72d370e0..a07bbb3fb 100644 --- a/core/src/processing/data/StringDict.java +++ b/core/src/processing/data/StringDict.java @@ -215,6 +215,11 @@ public class StringDict { } + public boolean hasKey(String key) { + return index(key) != -1; + } + + protected void create(String key, String value) { if (count == keys.length) { keys = PApplet.expand(keys);