From 59ba32f0285aa6d6b367e6283cae9268e8947fed Mon Sep 17 00:00:00 2001 From: jeff Date: Sat, 7 Mar 2015 16:00:44 -0500 Subject: match/unmatch button works --- src/cuchaz/enigma/convert/Matches.java | 38 ++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src/cuchaz/enigma/convert/Matches.java') diff --git a/src/cuchaz/enigma/convert/Matches.java b/src/cuchaz/enigma/convert/Matches.java index 5faa923..0b00b29 100644 --- a/src/cuchaz/enigma/convert/Matches.java +++ b/src/cuchaz/enigma/convert/Matches.java @@ -48,6 +48,22 @@ public class Matches implements Iterable { m_matches.add(match); indexMatch(match); } + + public void remove(ClassMatch match) { + for (ClassEntry sourceClass : match.sourceClasses) { + m_matchesBySource.remove(sourceClass); + m_uniqueMatches.remove(sourceClass); + m_ambiguousMatchesBySource.remove(sourceClass); + m_unmatchedSourceClasses.remove(sourceClass); + } + for (ClassEntry destClass : match.sourceClasses) { + m_matchesByDest.remove(destClass); + m_uniqueMatches.inverse().remove(destClass); + m_ambiguousMatchesByDest.remove(destClass); + m_unmatchedDestClasses.remove(destClass); + } + m_matches.remove(match); + } public int size() { return m_matches.size(); @@ -112,4 +128,26 @@ public class Matches implements Iterable { public ClassMatch getMatchByDest(ClassEntry destClass) { return m_matchesByDest.get(destClass); } + + public void removeSource(ClassEntry sourceClass) { + ClassMatch match = m_matchesBySource.get(sourceClass); + if (match != null) { + remove(match); + match.sourceClasses.remove(sourceClass); + if (!match.sourceClasses.isEmpty() || !match.destClasses.isEmpty()) { + add(match); + } + } + } + + public void removeDest(ClassEntry destClass) { + ClassMatch match = m_matchesByDest.get(destClass); + if (match != null) { + remove(match); + match.destClasses.remove(destClass); + if (!match.sourceClasses.isEmpty() || !match.destClasses.isEmpty()) { + add(match); + } + } + } } -- cgit v1.2.3