private void SearchName_Click(object sender, EventArgs e) { if (A.contains(textBoxName.Text)) { MessageBox.Show("Found \"" + textBoxName.Text + "\" in list.");// + "(" + ")"); } else { MessageBox.Show(textBoxName.Text + " not found!"); } //DoItAll(); }
static void ArrayListTest() { ArrayList <int> list = new ArrayList <int>(); for (int i = 0; i < 100; i++) { list.add(i); } Console.WriteLine("Size: " + list.size()); list = list.subList(0, 50); Console.WriteLine("Size: " + list.size()); list.print(); Console.WriteLine(list.isEmpty()); list.reverse(); list[0] = 350; Console.WriteLine(list.get(5)); Console.WriteLine(list[5]); Console.WriteLine(list.contains(3)); list.print(); }
/** * Adds a temp variable. */ public void addTempVar(String name) { if (!_tempVarList.contains(name)) { _tempVarList.add(name); } }
public void UpdateGenerator(Generator generator, int oldWatts) { if (generators.contains(generator)) { this.maxCapacity -= oldWatts; this.maxCapacity += generator.getWatts(); } }
//$goals 6 //$benchmark public void containsTest(ArrayList arrayList, Object o) { if (arrayList != null) { { /*$goal 0 reachable*/ } boolean ret_val = arrayList.contains(o); } else { { /*$goal 1 reachable*/ } } }
/** * <p>Adds an event listener that will be run when this confidence object is updated. The listener will be locked and * is likely to be invoked on a peer thread.</p> * * <p>Note that this is NOT called when every block arrives. Instead it is called when the transaction * transitions between confidence states, ie, from not being seen in the chain to being seen (not necessarily in * the best chain). If you want to know when the transaction gets buried under another block, implement a * {@link BlockChainListener}, attach it to a {@link BlockChain} and then use the getters on the * confidence object to determine the new depth.</p> */ public synchronized void addEventListener(Listener listener) { Preconditions.checkNotNull(listener); if (listeners == null) { listeners = new ArrayList <Listener>(2); } // Dedupe registrations. This makes the wallet code simpler. if (!listeners.contains(listener)) { listeners.add(listener); } }
public void testSuccessors() { ArrayList<String> locations = new ArrayList<String>(); // A locations.clear(); locations.add("B"); locations.add("C"); for (Action a : af.actions("A")) { Assert.assertTrue(locations.contains(((MoveToAction) a) .getToLocation())); Assert.assertTrue(locations.contains(rf.result("A", a))); } // B locations.clear(); locations.add("A"); locations.add("C"); locations.add("E"); for (Action a : af.actions("B")) { Assert.assertTrue(locations.contains(((MoveToAction) a) .getToLocation())); Assert.assertTrue(locations.contains(rf.result("B", a))); } // C locations.clear(); locations.add("A"); locations.add("B"); locations.add("D"); for (Action a : af.actions("C")) { Assert.assertTrue(locations.contains(((MoveToAction) a) .getToLocation())); Assert.assertTrue(locations.contains(rf.result("C", a))); } // D locations.clear(); locations.add("C"); for (Action a : af.actions("D")) { Assert.assertTrue(locations.contains(((MoveToAction) a) .getToLocation())); Assert.assertTrue(locations.contains(rf.result("D", a))); } // E locations.clear(); Assert.assertTrue(0 == af.actions("E").size()); }
void addResource(String name, string value) { string oldValue = _resources.get(name); if (oldValue == null || oldValue.equals(value)) { _resources.put(name, value); return; } if (oldValue.startsWith("<<")) { string oldValueStrip = oldValue.substring(2, oldValue.length() - 2); string valueStrip = value.substring(2, value.length() - 2); ArrayList <String> oldValueList = new ArrayList <String>(); for (String elt : oldValueStrip.split("\n")) { oldValueList.add(elt); } for (String elt : valueStrip.split("\n")) { if (!oldValueList.contains(elt)) { oldValueList.add(elt); } } StringBuilder sb = new StringBuilder(); sb.append("<<"); for (int i = 0; i < oldValueList.size(); i++) { if (i != 0) { sb.append("\n"); } sb.append(oldValueList.get(i)); } sb.append(">>"); _resources.put(name, sb.ToString()); } }
private static ArrayList getUniqueLabels(Fst fst, ArrayList arrayList) { ArrayList arrayList2 = new ArrayList(); Iterator iterator = arrayList.iterator(); while (iterator.hasNext()) { Pair pair = (Pair)iterator.next(); State state = (State)pair.getLeft(); int numArcs = state.getNumArcs(); for (int i = 0; i < numArcs; i++) { Arc arc = state.getArc(i); if (!arrayList2.contains(Integer.valueOf(arc.getIlabel()))) { arrayList2.add(Integer.valueOf(arc.getIlabel())); } } } return(arrayList2); }
private static State depthFirstSearchNext(Fst fst, State state, ArrayList arrayList, ArrayList[] array, HashSet hashSet) { int num = arrayList.size() - 1; ArrayList arrayList2 = array[state.getId()]; ((ArrayList)arrayList.get(num)).add(state); if (state.getNumArcs() != 0) { int num2 = 0; int numArcs = state.getNumArcs(); for (int i = 0; i < numArcs; i++) { Arc arc = state.getArc(i); if (arrayList2 == null || !arrayList2.contains(arc)) { num = arrayList.size() - 1; int num3 = num2; num2++; if (num3 > 0) { Connect.duplicatePath(num, fst.getStart(), state, arrayList); num = arrayList.size() - 1; ((ArrayList)arrayList.get(num)).add(state); } State nextState = arc.getNextState(); Connect.addExploredArc(state.getId(), arc, array); if (nextState.getId() != state.getId()) { Connect.depthFirstSearchNext(fst, nextState, arrayList, array, hashSet); } } } } int num4 = arrayList.size() - 1; hashSet.add(state); return(state); }
public void testRandomGeneration() { ArrayList<String> locations = new ArrayList<String>(); locations.add("A"); locations.add("B"); locations.add("C"); locations.add("D"); locations.add("E"); for (int i = 0; i < locations.size(); i++) { Assert.assertTrue(locations.contains(aMap .randomlyGenerateDestination())); } }
public MyBot() { // Setting Default Information for API discord = new DiscordClient(x => { x.LogLevel = LogSeverity.Info; x.LogHandler = Log; }); discord.UsingCommands(x => { x.PrefixChar = '!'; x.AllowMentionPrefix = false; }); // Base Commands commands.CreateCommand("pay") .Parameter("TargetUser", ParameterType.Required) .Parameter("Amount", ParameterType.Required) .Do(async(e) => { Args = e.GetArg("TargetUser"); // Checking if such bank account is existant or if said user has permissions if (userEcon.ContainsKey(Args) && !(BannedList.contains(Args)) && !(BannedList.contains(e.User.Name)) && RankPerms.contains(Args, pay) || UserPerms.contains(Args, pay) && RankPerms.contains(e.User.Name, pay, ) || UserPerms.contains(e.User.Name, pay)) { // Same base system since if it works dont change it Amount = userEcon[e.User.Name.ToLower()] -= Int32.Parse(e.GetArg("Amount")); Amount2 = userEcon[Args.ToLower()] += Int32.Parse(e.GetArg("Amount")); userEcon.Remove(Args.ToLower()); userEcon.Remove(e.User.Name.ToLower()); userEcon.Add(e.User.Name.ToLower(), Amount); userEcon.Add(Args.ToLower(), Amount2); await e.Channel.SendMessage(e.User.Name + " has paid " + Args + " " + e.GetArg("Amount") + EconomyName); } else if (userEcon.ContainsKey(Args)) { await e.Channel.SendMessage("Fixed!"); } else if (BannedList.contains(Args)) { await e.Channel.SendMessage(Args + " Is currently banned!"); } else if (Bannlist.contains(e.User.Name)) { await e.Channel.SendMessage(e.User.Name + " Is currently banned!") } else { await e.Channel.SendMessage("Permission Error, Check with Administrator if you think this is incorrect!") } }); commands.CreateCommand("SaveConfig") .Do(async(e) => { }); commands.CreateCommand("bank") .Parameter("User", ParameterType.Optional) .Do(async(e) => { if (!(userEcon.ContainsKey(e.User.Name.ToLower()))) { UserEconList[IndexLoc] = e.User.Name.ToLower() + "[" + 100 + "]"; userEcon.Add(e.User.Name.ToLower(), 100); } if (!(userEcon.ContainsKey(e.GetArg("User").ToLower()))) { UserEconList[IndexLoc] = e.GetArg("User") + "[" + 100 + "]"; userEcon.Add(e.GetArg("User").ToLower(), 100); } if (e.GetArg("User").Equals(" ") || e.GetArg("User").Equals("")) { await e.Channel.SendMessage(e.User.Name + " You have " + userEcon[e.User.Name.ToLower()] + " x"); } else { await e.Channel.SendMessage(e.GetArg("User") + " Has " + userEcon[e.GetArg("User").ToLower()] + " x"); } }); discord.ExecuteAndWait(async() => { await discord.Connect(PrivateKey, TokenType.Bot); }); }
protected internal virtual void loadHMMPool(bool useCDUnits, HTKLoader.HTKStruct htkModels, string path) { if (!this.tie1ph) { Iterator iterator = htkModels.hmmsHTK.get1phIt(); while (iterator.hasNext()) { SingleHMM singleHMM = (SingleHMM)iterator.next(); if (singleHMM == null) { break; } string baseName = singleHMM.getName(); string text; if (String.instancehelper_equals(baseName, "sil") || String.instancehelper_equals(baseName, "sp") || String.instancehelper_equals(baseName, "bb") || String.instancehelper_equals(baseName, "xx") || String.instancehelper_equals(baseName, "hh")) { text = "filler"; } else { text = "nofiller"; } int trIdx = singleHMM.trIdx; int nstates = singleHMM.getNstates(); int[] array = new int[singleHMM.getNbEmittingStates()]; int num = 0; for (int i = 0; i < nstates; i++) { if (singleHMM.isEmitting(i)) { HTK.HMMState state = singleHMM.getState(i); array[num] = htkModels.hmmsHTK.getStateIdx(state); num++; } } Unit unit = this.unitManager.getUnit(baseName, String.instancehelper_equals(text, "filler")); this.contextIndependentUnits.put(unit.getName(), unit); if (this.logger.isLoggable(Level.FINE)) { this.logger.fine(new StringBuilder().append("Loaded ").append(unit).toString()); } if (unit.isFiller() && String.instancehelper_equals(unit.getName(), "SIL")) { unit = UnitManager.__SILENCE; } float[][] transitionMatrix = (float[][])this.matrixPool.get(trIdx); SenoneSequence senoneSequence = this.getSenoneSequence(array); SenoneHMM hmm = new SenoneHMM(unit, senoneSequence, transitionMatrix, HMMPosition.lookup("-")); this.hmmManager.put(hmm); } } else { for (int j = 0; j < htkModels.hmmsHTK.getNhmms(); j++) { SingleHMM singleHMM = htkModels.hmmsHTK.getHMM(j); if (singleHMM == null) { break; } string baseName = singleHMM.getBaseName(); if (!this.contextIndependentUnits.containsKey(baseName)) { string text; if (String.instancehelper_equals(baseName, "SIL") || String.instancehelper_equals(baseName, "SP") || String.instancehelper_equals(baseName, "BB") || String.instancehelper_equals(baseName, "XX") || String.instancehelper_equals(baseName, "HH")) { text = "filler"; } else { text = "nofiller"; } int trIdx = singleHMM.trIdx; int nstates = singleHMM.getNstates(); int[] array = new int[singleHMM.getNbEmittingStates()]; int num = 0; for (int i = 0; i < nstates; i++) { if (singleHMM.isEmitting(i)) { HTK.HMMState state = singleHMM.getState(i); array[num] = htkModels.hmmsHTK.getStateIdx(state); num++; } } Unit unit = this.unitManager.getUnit(baseName, String.instancehelper_equals(text, "filler")); this.contextIndependentUnits.put(unit.getName(), unit); if (this.logger.isLoggable(Level.FINE)) { this.logger.fine(new StringBuilder().append("Loaded ").append(unit).toString()); } if (unit.isFiller() && String.instancehelper_equals(unit.getName(), "SIL")) { unit = UnitManager.__SILENCE; } float[][] transitionMatrix = (float[][])this.matrixPool.get(trIdx); SenoneSequence senoneSequence = this.getSenoneSequence(array); SenoneHMM hmm = new SenoneHMM(unit, senoneSequence, transitionMatrix, HMMPosition.lookup("-")); this.hmmManager.put(hmm); } } } string text2 = ""; Unit unit2 = null; int[] ssid = null; SenoneSequence senoneSequence2 = null; ArrayList arrayList = new ArrayList(); Iterator iterator2 = htkModels.hmmsHTK.get3phIt(); while (iterator2.hasNext()) { SingleHMM singleHMM2 = (SingleHMM)iterator2.next(); if (singleHMM2 == null) { break; } string baseName2 = singleHMM2.getBaseName(); string text3 = singleHMM2.getLeft(); string text4 = singleHMM2.getRight(); if (String.instancehelper_equals(text3, "-")) { text3 = "SIL"; } if (String.instancehelper_equals(text4, "-")) { text4 = "SIL"; } string text5 = new StringBuilder().append(text3).append(' ').append(baseName2).append(' ').append(text4).toString(); if (!arrayList.contains(text5)) { arrayList.add(text5); text5 = "i"; int trIdx2 = singleHMM2.trIdx; int nstates = singleHMM2.getNstates(); int[] array2 = new int[singleHMM2.getNbEmittingStates()]; int num2 = 0; for (int k = 0; k < nstates; k++) { if (singleHMM2.isEmitting(k)) { HTK.HMMState state2 = singleHMM2.getState(k); array2[num2] = htkModels.hmmsHTK.getStateIdx(state2); num2++; } } if (useCDUnits) { string text6 = new StringBuilder().append(baseName2).append(' ').append(text3).append(' ').append(text4).toString(); Unit unit3; if (String.instancehelper_equals(text6, text2)) { unit3 = unit2; } else { LeftRightContext context = LeftRightContext.get(new Unit[] { (Unit)this.contextIndependentUnits.get(text3) }, new Unit[] { (Unit)this.contextIndependentUnits.get(text4) }); unit3 = this.unitManager.getUnit(baseName2, false, context); } text2 = text6; unit2 = unit3; if (this.logger.isLoggable(Level.FINE)) { this.logger.fine(new StringBuilder().append("Loaded ").append(unit3).toString()); } float[][] transitionMatrix2 = (float[][])this.matrixPool.get(trIdx2); SenoneSequence senoneSequence3 = senoneSequence2; if (senoneSequence3 == null || !this.sameSenoneSequence(array2, ssid)) { senoneSequence3 = this.getSenoneSequence(array2); } senoneSequence2 = senoneSequence3; ssid = array2; SenoneHMM hmm2 = new SenoneHMM(unit3, senoneSequence3, transitionMatrix2, HMMPosition.lookup(text5)); this.hmmManager.put(hmm2); } } } }
//$goals 6 //$benchmark public void containsTest(ArrayList arrayList, Object o) { if (arrayList != null) { {/*$goal 0 reachable*/} boolean ret_val = arrayList.contains(o); } else { {/*$goal 1 reachable*/} } }