package sds.classfile.bytecode;

import java.util.Map;
import java.util.concurrent.ConcurrentSkipListMap;

/**
 * This class is for
 * {@link OpcodeInfo <code>OpcodeInfo</code>}
 * sequence of method.
 * @author inagaki
 */
public class Opcodes {
	private Map<Integer, OpcodeInfo> opcodeMap;

	/**
	 * constructor.
	 */
	public Opcodes() {
		this.opcodeMap = new ConcurrentSkipListMap<>();
	}

	/**
	 * adds opcode to map.
	 * @param key index into the code array
	 * @param element opcode
	 */
	public void add(int key, OpcodeInfo element) {
		opcodeMap.put(key, element);
	}

	/**
	 * returns opcode of specified pc.
	 * @param pc index into the code array
	 * @return opcode
	 */
	public OpcodeInfo get(int pc) {
		return opcodeMap.get(pc);
	}

	/**
	 * returns opcodes.
	 * @return opcodes.
	 */
	public OpcodeInfo[] getAll() {
		return opcodeMap.values().toArray(new OpcodeInfo[0]);
	}

	/**
	 * returns values of pc of opcode.
	 * @return values
	 */
	public int[] getKeys() {
		return opcodeMap.keySet()
			.stream().mapToInt(Integer::intValue).toArray();
	}
}
@@ -383,24 +383,132 @@
 ap%3C%3E();%0A%09%7D%0A%0A
+%09/**%0A%09 * returns opcode map size.%0A%09 * @return size%0A%09 */%0A%09public int size() %7B%0A%09%09return opcodeMap.size();%0A%09%7D%0A%0A
 %09/**%0A%09 * add
@@ -1166,10 +1166,197 @@
 ay();%0A%09%7D
+%0A%0A%09/**%0A%09 * returns opcode map.%0A%09 * @return opcode map%0A%09 */%0A%09public ConcurrentSkipListMap%3CInteger, OpcodeInfo%3E getMap() %7B%0A%09%09return (ConcurrentSkipListMap%3CInteger, OpcodeInfo%3E)opcodeMap;%0A%09%7D
 %0A%7D

add method of returning map size.