From 295eceece371b516e771de93b6127bf728999483 Mon Sep 17 00:00:00 2001 From: jeff Date: Sat, 26 Jul 2014 19:24:00 -0400 Subject: initial commit so far source analysis is working. =) --- src/cuchaz/enigma/analysis/SourceIndex.java | 57 +++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/cuchaz/enigma/analysis/SourceIndex.java (limited to 'src/cuchaz/enigma/analysis/SourceIndex.java') diff --git a/src/cuchaz/enigma/analysis/SourceIndex.java b/src/cuchaz/enigma/analysis/SourceIndex.java new file mode 100644 index 0000000..a4b5329 --- /dev/null +++ b/src/cuchaz/enigma/analysis/SourceIndex.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 2014 Jeff Martin. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Public License v3.0 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/gpl.html + * + * Contributors: + * Jeff Martin - initial API and implementation + ******************************************************************************/ +package cuchaz.enigma.analysis; + +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +import jsyntaxpane.Token; + +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; + +public class SourceIndex implements Iterable> +{ + private BiMap m_entryToToken; + private BiMap m_tokenToEntry; + + public SourceIndex( ) + { + m_entryToToken = HashBiMap.create(); + m_tokenToEntry = m_entryToToken.inverse(); + } + + public void add( Object entry, Token token ) + { + m_entryToToken.put( entry, token ); + } + + public Iterator> iterator( ) + { + return m_entryToToken.entrySet().iterator(); + } + + public Set tokens( ) + { + return m_entryToToken.values(); + } + + public Object getEntry( Token token ) + { + return m_tokenToEntry.get( token ); + } + + public Object getToken( Object entry ) + { + return m_entryToToken.get( entry ); + } +} -- cgit v1.2.3