1 package net.mograsim.machine.mnemonics;
3 import java.util.Arrays;
5 import java.util.stream.Collectors;
7 public class MnemonicFamily
9 private final Mnemonic[] values;
10 private final Map<String, Mnemonic> byText;
11 private final int vectorLenght;
13 public MnemonicFamily(Mnemonic... values)
16 if(values.length == 0)
20 vectorLenght = values[0].getVector().width();
21 for(int i = 1; i < values.length; i++)
22 if(values[i].getVector().width() != vectorLenght)
23 throw new IllegalArgumentException("MnemonicFamily is not of uniform vector length!");
25 byText = Arrays.stream(values).collect(Collectors.toMap(m -> m.getText(), m -> m));
28 public Mnemonic[] getValues()
30 return values.clone();
33 public Mnemonic get(String text)
35 return byText.get(text);
38 public boolean contains(Mnemonic m)
41 return m.equals(byText.get(m.getText()));
51 public int getVectorLength()