text stringlengths 14 410k | label int32 0 9 |
|---|---|
private boolean isOptimal(double[] b, double[] c) {
double[] x = primal();
double[] y = dual();
double value = value();
// check that value = cx = yb
double value1 = 0.0;
for (int j = 0; j < x.length; j++)
value1 += c[j] * x[j];
double value2 = 0.0;
... | 4 |
public static void validate(List<Long> pointToValidate,
List<Long> startPoint, List<Long> endPoint)
throws SizeNotEqualException, InvalidPointException {
int size = pointToValidate.size();
if (size != startPoint.size()) {
throw new SizeNotEqualExce... | 5 |
protected final java.lang.Object iterateReader(XMLStreamReader toReader, java.lang.Object toObject, XMLFormatType toFormatType)
{
java.lang.Object loReturn = null;
try
{ while(toReader.hasNext())
{
switch(toReader.getEventType())
{
... | 9 |
public static void main( String[] args ) throws NoSuchFieldException, SecurityException, NoSuchMethodException,
InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException,
ClassNotFoundException
{
String stringer = "this is a String called str... | 8 |
public void setCodigo(String codigo) {
this.codigo = codigo.isEmpty() ? "sem código" : codigo;
} | 1 |
public void run(){
try
{
buff = new byte[Optiums.BUFF_SIZE];
recordFile = new FileOutputStream(new File(Optiums.FILE_RECORD_NAME + "." +
Optiums.FILE_TYPE.toString().toLowerCase()));
outpuStream = new OutputStream() {
private byte l = 0; ... | 4 |
@SuppressWarnings("unchecked")
public void registerListener( EventListener listener, Plugin plugin )
{
List< Method > methods = new ArrayList< Method >();
Collections.addAll( methods, listener.getClass().getMethods() );
for( Method method : methods )
{
EventHandler handler = method.getAnnotation( Eve... | 7 |
public void DFS(int a,int b){
Stack<Node> s= new Stack<Node>();
ArrayList<Integer> visited= new ArrayList<Integer>();
Node src=new Node(a);
Node dest= new Node(b);
s.push(src);
while(!s.empty()){
Node tmp=s.pop();
if(!visited.contains(new Integer(tmp.getData()))){
System.out.println(tmp.getData())... | 5 |
private final void sendObjectPlacement(final MapleCharacter c) {
if (c == null) {
return;
}
for (final MapleMapObject o : getAllMonster()) {
updateMonsterController((MapleMonster) o);
}
for (final MapleMapObject o : getMapObjectsInRange(c.getPosition(), Ga... | 5 |
public void criaUSER(Usuario user) throws SQLException {
Connection conexao = null;
PreparedStatement comando = null;
try {
conexao = BancoDadosUtil.getConnection();
if ("Diretor".equals(user.getTipo())) {
comando = conexao.prepareStatement(SQL_INSERT_D... | 7 |
private void findNextElement()
{
try
{
if(parser.getElement() != null && parser.getElement().hasChildren())
parser.down();
while(true)
{
parser.next();
if(parser.getElement() != null)
{
foundNext = true;
return;
}
else
{
if(parser.getDept... | 6 |
public void initialize(final ClientDavInterface connection) throws Exception {
DataModel dataModel = connection.getDataModel();
ConfigurationAuthority configurationAuthority = null;
if(_kv != null && _kv.length() != 0) {
try {
long id = Long.parseLong(_kv);
SystemObject object = dataModel.getObject(id)... | 8 |
private void handleFailed() {
uncompletedCount = 0;
completedCount = 0;
for (OnDemandData onDemandData = (OnDemandData) requested.peekLast(); onDemandData != null; onDemandData = (OnDemandData) requested
.reverseGetNext())
if (onDemandData.incomplete)
uncompletedCount++;
else
completedCount++;
... | 5 |
public void log( Level level,
String trace,
String msg ) {
// Forward the call the the default logger
super.log( level, trace, msg );
// Then add the event to the HTTPD statistics
if( level.equals(Level.SEVERE) ) {
this.getHandler().getRuntimeStatistics().reportSevere();
} else if( level.equal... | 7 |
public static void saveFile(String file, String data, boolean append) throws IOException {
BufferedWriter bw = null;
OutputStreamWriter osw = null;
File f = new File(file);
FileOutputStream fos = new FileOutputStream(f, append);
try {
// write UTF8 BOM mark if file is empty
... | 4 |
@Override
public double getTip() {
double tip = 0.00; // always initialize local variables
switch(serviceQuality) {
case GOOD:
tip = baseTipPerBag * bagCount * (1 + goodRate);
break;
case FAIR:
tip = baseTipPerBag * bagCount * ... | 3 |
public Collection<String> getClassificacao(String cod_competicao) {
try {
Collection<String> col = new ArrayList<String>();
Statement stm = conn.createStatement();
ResultSet rs = stm.executeQuery("select Jogador.nome,equipa.cod_equipa as Equipa,golo from Jogador,Marcadores,Eq... | 2 |
public static final void setPrintStream(PrintStream stream) {
if (!Debug.DEV_MODE) {
if (stream == null) {
stream = System.out;
}
if (OUT != stream && OUT != System.out) {
OUT.close();
}
OUT = stream;
}
} | 4 |
public static void recCall(int num) {
LinkedList<Integer> queue = new LinkedList<Integer>();
queue.add(num);
queue.add(-1);
Hashtable<Integer, ArrayList<Integer>> memo = new Hashtable<Integer, ArrayList<Integer>>();
boolean firstPlayerTurn = true;
while (!queue.isEmpty()) {
Integer currNum = queue.poll... | 7 |
public void wdgmsg(Widget sender, String msg, Object... args) {
if (sender == cbtn) {
clbk.result(false);
close();
return;
}
super.wdgmsg(sender, msg, args);
} | 1 |
public final Action[] createDefaultFontFaceActions() {
String[] families = GraphicsEnvironment.getLocalGraphicsEnvironment()
.getAvailableFontFamilyNames();
Map fontFamilyRange = Collections.synchronizedMap(new HashMap());
Action a = null;
for (int i = 0; i < families.length; i++) {
if (f... | 4 |
public String[] getOptions() {
Vector<String> result;
result = new Vector<String>();
result.add("-mean-prec");
result.add("" + getMeanPrec());
result.add("-stddev-prec");
result.add("" + getStdDevPrec());
result.add("-col-name-width");
result.add("" + getColNameWidth(... | 7 |
private static float getUnitFactor(String unit)
{
//byte scale
if(unit.equals("KB"))
return 1/1024;
if(unit.equals("MB"))
return 1;
if(unit.equals("GB"))
return 1024;
if(unit.equals("TB"))
return 1024 * 1024 ;
//freq scale
if(unit.equals("Hz"))
return 1;
if(unit.equals("KHz"))
ret... | 8 |
public static int[] selectionSort(int[] array, boolean ascendingOrder) {
if (array != null && array.length > 1) {
int lengthLessOne = array.length - 1;
int minValue;
int minIndex;
for (int i = 0; i < lengthLessOne; i++) {
minValue = array[i];
minIndex = i;
for (int j = i + 1; j < array.len... | 6 |
@Override
public V merge(
final K key,
final V value,
final BiFunction<? super V, ? super V, ? extends V> remappingFunction) {
throw new UnsupportedOperationException();
} | 3 |
public void renderPlayer(int xp, int yp, Sprite sprite)
{
xp -= xOffset;
yp -= yOffset;
for(int y = 0; y < 32; y++)
{
int ya = y + yp;
for(int x = 0; x < 32; x++)
{
int xa = x + xp;
if(xa < -32 || xa >= width || ya < 0 || ya >= height) break;
if(xa < 0) xa = 0;
int col = sprite.pixels[... | 8 |
public static Map<String, CyIdentifiable> getPDBChains(String queryString,
Map<String, CyIdentifiable>reverseMap,
Map<CyIdentifiable, List<PDBStructure>>chainMap)
... | 8 |
@Test
public void testDrawWorld() {
Cell[][] cells = new Cell[][]{
{Cell.LIVING, Cell.DEAD},
{Cell.DEAD, Cell.LIVING},
};
Integer numberOfLivingCells = 0;
Integer numberOfDeadCells = 0;
for (int i = 0; i < cells.length; i++) {
for (int j = 0; j < cells[i].length; j++) {
if (cells[i][j] == Cel... | 3 |
public void cmpl(final Type type) {
mv.visitInsn(type == Type.FLOAT_TYPE ? Opcodes.FCMPL : Opcodes.DCMPL);
} | 1 |
@Override
public boolean takePoints(String name, int points) {
if(getPoints(name)<points){
return false;
}
try {
PointsAPI.modifyPointsToPlayer(name, points, Type.RemovePoints);
} catch (Exception e) {
return false;
}
return true;
} | 2 |
public List<Element> getNodes(String xpath)
{
try
{
XPathFactory xpathfactory = XPathFactory.newInstance();
XPath xPath = xpathfactory.newXPath();
XPathExpression expr = xPath.compile(xpath);
Object result = expr.evaluate(domNode, XPathConstants.NODESE... | 3 |
public String getName() {
return name;
} | 0 |
private void LoadContent() {
try {
URL moonLanderMenuImgUrl = this.getClass().getResource("/raceresources/resources/images/stardust.png");
moonLanderMenuImg = ImageIO.read(moonLanderMenuImgUrl);
} catch (IOException ex) {
Logger.getLogger(Framework.class.getName()).lo... | 1 |
@Override public void run()
{
while(!stop && !hasStopped()) {
redirectStdin();
redirectStdout();
try {
for(String s : getEvents()) {
EventHandler.handle(new Event(s));
}
} catch (Exception e) {
e.printStackTrace();
}
try { sleep(100); } catch(InterruptedException e) {}
}
// If the server ... | 6 |
public static Date[] getColumnDateValues(CSTable t, String columnName) {
int col = columnIndex(t, columnName);
if (col == -1) {
throw new IllegalArgumentException("No such column: " + columnName);
}
Conversions.Params p = new Conversions.Params();
p.add(String.class,... | 2 |
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://down... | 6 |
private void iniciaRodada() {
criaPecas();
int n = distribuiPecas();
pontaDir = pontaEsq = n;
int i = prim;
vez = i % 4;
turno = 0;
while (vencedor == 5) {
vez = i % 4;
for (int j = 0; j < jogadores.length; j++) {
jogadores[... | 9 |
private void ok() {
this.styleName = (File) styles.getSelectedItem();
this.shouldProceed = true;
hide();
} | 0 |
public Item removeFirst() {
if (isEmpty())
throw new java.util.NoSuchElementException();
else if (size() == 1) {
Item item = first.item;
first = null;
last = null;
size--;
return item;
}
Item item = first.item;
... | 2 |
public SoundData(IAudioDevice device, String fileName) throws IOException {
this.device = device;
this.id = 0;
try {
this.id = loadAudio(device, fileName);
} catch (UnsupportedAudioFileException e) {
throw new IOException(e);
}
} | 1 |
private static boolean collapseIfIf(IfNode rtnode) {
if (rtnode.edgetypes.get(0) == 0) {
IfNode ifbranch = rtnode.succs.get(0);
if (ifbranch.succs.size() == 2) {
// if-if branch
if (ifbranch.succs.get(1).value == rtnode.succs.get(1).value) {
IfStatement ifparent = (IfStateme... | 8 |
public void deleteClientInfo(String t_name) {
ClientInfo temp = this.find(t_name);
if (temp != null)
client_list.remove(temp);
} | 1 |
@Override
public void mouseClicked(int button, int x, int y, int clickcount) {
Client.debug("clicked in a window x:" + x + " y:" + y );
boolean found = false;
for (GUIObject obj : objects.values()) {
if (!obj.isInput())
continue;
if ( x >= obj.getRealX() && x < obj.getRealX()+obj.getRealWidth() ) {... | 8 |
protected void btnSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSalvarActionPerformed
if(JOptionPane.showConfirmDialog(rootPane, "Você tem certeza que deseja Salvar ?")== 0){
if(txtNome.getText().isEmpty()){
JOptionPane.showMessageDialog(rootPane, "O cam... | 9 |
public void setId(String id) {
this.id = id;
setDirty();
} | 0 |
public JavaFileManagerClassLoader(JavaFileManager fileManager, final ClassLoader parent) {
super(parent);
if (fileManager == null) {
throw new NullPointerException("fileManager");
}
this.fileManager = fileManager;
} | 1 |
public void keyPressed(KeyEvent e)
{
int i = targetList.getSelectedIndex();
switch (e.getKeyCode())
{
case KeyEvent.VK_UP:
i = targetList.getSelectedIndex() - 1;
if (i < 0)
{
i... | 4 |
private static void findPairIntersections() {
for (Pair p1 : values) {
Card[] c1 = p1.cards;
int i1 = p1.ordinal;
for (Pair p2 : values) {
int i2 = p1.ordinal;
Card[] c2 = p2.cards;
intersectsPair[i1][i2] = false;
if(c1[0] == c2[0]) intersectsPair[i1][i2] = true;
if(c1[0] == c2[1]) inters... | 6 |
public void updatePacketTime(int packetTime) {
lastPacketTime = packetTime;
} | 0 |
public Component getTreeCellRendererComponent(
JTree tree,Object value, boolean selected, boolean expanded,
boolean leaf, int row, boolean hasFocus) {
// Allow the original renderer to set up the label
Component c = super.getTreeCellRendererComponent(
tree, value, sele... | 4 |
public static int spawn_in_out_err(String command, String infile, String outfile, String errfile) {
Process p;
try {
p = Runtime.getRuntime().exec(command);
} catch (IOException e) {
return -1;
}
try {
if (infile != null) {
(new Xfer(new FileInputStream(infile), p.getOutputStream())).start();
... | 6 |
public void rotate(int[][] matrix) {
int length = matrix.length;
int[][] array = new int[length][length];
for(int i =0;i < length;i++){
for(int j =0;j<length;j++){
array[j][length-1-i] = matrix[i][j] ;
}
}
for(int i =0;i < length;i++){
... | 4 |
@Override
public String toString() {
return this.def + "@" + this.key;
} | 0 |
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String username = request.getParameter("username");
String password = request.getParameter("password");
List<User> list = DB.getAll();
for(User user : list){
if(user.getUsername().equals(u... | 3 |
private TeamMember findPlayer(String name, String number, TeamMember defaultReturn) {
TeamMember playerToFind = new Player(name, "Team", number, "age");
for (Player player : players) {
if (player.equals(playerToFind)){
return player;
}
}
return def... | 2 |
public static final void main(String[] args) throws Exception {
if(args.length < 1 || args.length > 2) {
System.err.println("usage: Ping host [count]");
System.exit(1);
}
final ScheduledThreadPoolExecutor executor =
new ScheduledThreadPoolExecutor(2);
try{
final InetAddress add... | 9 |
static void testValidity(Object o) throws JSONException {
if (o != null) {
if (o instanceof Double) {
if (((Double)o).isInfinite() || ((Double)o).isNaN()) {
throw new JSONException(
"JSON does not allow non-finite numbers.");
... | 7 |
public void testLastDay() {
Date date = new Date();
Date r = DateUtils.getLastDayOfTheMonth(date);
System.out.println(r);
} | 0 |
void setExampleWidgetForeground () {
if (colorAndFontTable == null) return; // user cannot change color/font on this tab
Control [] controls = getExampleControls ();
if (!instance.startup) {
for (int i = 0; i < controls.length; i++) {
controls[i].setForeground (foregroundColor);
}
}
/* Set the foreg... | 6 |
public void loadConfig() {
localeFileName = config.getString("locale.filename");
iInterval = config.getInt("interval");
iQuota = config.getInt("quota");
iBreakMax = config.getInt("block-break.max");
iBreakMult = config.getInt("block-break.multiplier");
iPlaceMax = config.getInt("block-place.max");
iPla... | 3 |
public boolean equals(final Object obj) {
return (obj instanceof NameAndType)
&& ((NameAndType) obj).name.equals(name)
&& ((NameAndType) obj).type.equals(type);
} | 2 |
public Boolean estocarNovos(List<Estoque> estoques) {
Boolean sucesso = false;
if (estoques != null) {
Connection connection = conexao.getConnection();
try {
String valorDoComandoUm = comandos.get("estocarNovos" + 1);
String valorDoComandoDois = co... | 7 |
@Override
public Component getListCellRendererComponent(JList list,
Object value, int index, boolean isSelected, boolean cellHasFocus) {
setText((value == null) ? "" : value.toString());
return this;
} | 1 |
@Override
public void setValueAt(Object value, final int row, final int col) {
final String key = this.propNames.get(row);
final WidgetProperty p = this.dataMap.get(key);
p.setValue(value);
Object o;
if ((this.selectedComponents != null)
&& !this.selectedComponents.isEmpty()) {
o = this.selectedCompon... | 9 |
public void testGetIntervalConverter() {
IntervalConverter c = ConverterManager.getInstance().getIntervalConverter(new Interval(0L, 1000L));
assertEquals(ReadableInterval.class, c.getSupportedType());
c = ConverterManager.getInstance().getIntervalConverter("");
assertEquals(Stri... | 2 |
public void move() {
if (isFalling) {
dy = dy+gravity;
y += dy;
}
else {
y -= dy;
dy = dy+antiGravity;
}
if (dy < 0.01f) {
isFalling = true;
dy = 0.02f;
}
if (y < 0) {
isFalling = true;
dy = 0.02f;
move();
}
} | 3 |
@Override
public NfcMessage write(NfcMessage input) throws IOException {
if (!isEnabled()) {
if (Config.DEBUG)
Log.d(TAG, "could not write message, reader is not enabled");
eventHandler.handleMessage(NfcEvent.FATAL_ERROR, NFCTRANSCEIVER_NOT_CONNECTED);
return new NfcMessage(Type.ERROR).sequenceNumbe... | 9 |
public synchronized void sortBy(int dim)
{
if((dim<1)||(dim>dimensions))
throw new java.lang.IndexOutOfBoundsException();
dim--;
if(stuff!=null)
{
final TreeSet<Object> sorted=new TreeSet<Object>();
Object O=null;
for (final Object[] name : stuff)
{
O=(name)[dim];
if(!sorted.contains(O))... | 8 |
public void place(int x, int y) {
if (this instanceof RockTower &&player.getGold()>=600) {
player.addTower(new RockTower(player, player.getTowers().size(), x, y));
player.pay(600);
} else if (this instanceof SpikyTower&&player.getGold()>=1000) {
player.addTower(new SpikyTower(player, player.getTowers().siz... | 7 |
public int evaluate (AbstractPlay play, Player cpu, int largestCapture) {
int evaluation = evaluateRecursively(play, cpu);
if (play.eatNumber() < largestCapture)
evaluation--;
return evaluation;
} | 1 |
private boolean precisaAutenticar(String url) {
return !url.contains("index.xhtml")
&& !url.contains("institucional.xhtml")
&& !url.contains("area-do-cliente.xhtml")
&& !url.contains("contato.xhtml")
&& !url.contains("javax.faces.resources");
} | 4 |
@Override
public void run(int interfaceId, int componentId) {
if (stage == -1) {
stage = 0;
sendEntityDialogue(
SEND_2_TEXT_CHAT,
new String[] {
NPCDefinitions.getNPCDefinitions(npcId).name,
"You have already learned the first thing needed to",
"succeed in this world talking to o... | 7 |
public static OS getPlatform() {
String osName = System.getProperty("os.name").toLowerCase();
if (osName.contains("win")) {
return OS.windows;
}
if (osName.contains("mac")) {
return OS.macos;
}
if (osName.contains("solaris")) {
return OS.solaris;
}
if (osName... | 6 |
public Export(RSInterface main) {
if (main == null) {
JOptionPane.showMessageDialog(null, "This is not a valid interface!");
return;
}
this.main = main;
setChildren();
if (layers != null && !layers.isEmpty()) {
setSubChildren();
}
if (subchildren != null && !subchildren.isEmpty()) {
setSubSubC... | 5 |
public void actionPerformed(ActionEvent e) {
JComponent c = (JComponent) environment.getActive();
PrintUtilities.printComponent(c);
} | 0 |
public static Vector2f rectCollide(Vector2f oldPos, Vector2f newPos, Vector2f size1, Vector2f pos2, Vector2f size2)
{
Vector2f result = new Vector2f(1,1);
if(!(newPos.getX() + size1.getX() < pos2.getX() ||
newPos.getX() - size1.getX() > pos2.getX() + (size2.getX() * size2.getX()) ||
oldPos.getY() + size1... | 8 |
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jPanelBusca = new javax.swing.JPanel();
jScrollPane4 = new javax.swing.JScrollPane();
tbProjetos = new javax.swing.JTable();
t... | 2 |
public void stateChanged(ChangeEvent e) {
if (model.getLightSource() == null)
return;
Object o = e.getSource();
if (o instanceof JSlider) {
JSlider source = (JSlider) o;
if (!source.getValueIsAdjusting()) {
model.setLightSourceInterval((int) ((200 + (source.getMaximum() - source.getValue()) * 20) / m... | 7 |
public void dbData(int uName) {
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e) {
System.out.println("Where is your MySQL JDBC Driver?");
e.printStackTrace();
}
if (uName >= 0) {
PreparedStatement ps = null... | 6 |
public String getConfigPath(String filename) {
if (eng.isApplet()) return null;
File jgamedir;
try {
jgamedir = new File(System.getProperty("user.home"), ".jgame");
} catch (Exception e) {
// probably AccessControlException of unsigned webstart
return null;
}
if (!jgamedir.exists()) {
// try to ... | 9 |
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://down... | 7 |
private String[] splitString(String ipFormula) throws ScriptSyntaxException {
LinkedList<String> tokens = new LinkedList<String>();
int braces=0;//level of braces
//considering that there is always only one space
int posBegin=0;
int posEnd=0;
while (posEnd<ipFormula.length()){
if (isSpace(ipFormula... | 9 |
public static FlacMetadataBlock create(InputStream inp) throws IOException {
int typeI = inp.read();
if(typeI == -1) {
throw new IllegalArgumentException();
}
byte type = IOUtils.fromInt(typeI);
byte[] l = new byte[3];
IOUtils.readFully(inp, l);
int length = (in... | 3 |
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://down... | 6 |
public final JSONObject optJSONObject(int index) {
Object o = opt(index);
return o instanceof JSONObject ? (JSONObject)o : null;
} | 1 |
private boolean first_round_strategy() {
if (bowlId < chooseLimit) {
maxScoreSoFar = Math.max( maxScoreSoFar, get_bowl_score(bowl) );
System.out.println("Not reached chooseLimit yet, updated maxScoreSoFar = " + maxScoreSoFar);
return false;
} else {
if (ge... | 2 |
@Override
public int eatNumber() {
return 0;
} | 0 |
public Game() {
Level level = new SpawnLevel(this);
currentScreen = new GameScreen(this, level);
mouse = new Mouse(this);
addMouseListener(mouse);
keyboard = new Keyboard(this);
addKeyListener(keyboard);
player = new Player(level, 30, 100);
} | 0 |
public double visibleBias(int index) {
if(index < 0 || index >= m)
throw new RuntimeException("given m=" + m + ", illegal value for index: " + index);
return _visibleBias[index];
} | 2 |
@Override
public int compareTo(Entity o) {
if (id > o.id) {
return 1;
}
if (id < o.id) {
return -1;
}
return 0;
} | 2 |
@Transactional
public Journal getOrCreateJournal(String name, Date date) {
Journal journal = journalsDao.getByName(name);
if (journal != null) {
Date startDate = dateService.getStartOfDay(date);
Date endDate = dateService.getNextDay(date);
journal.setTasks(tasksDa... | 1 |
private void refreshStatistics(ArrayList<T[]> gens) {
double max, min, avg, current;
avg = max = min = problem.costFunction(gens.get(0));
for (int i = 1; i < gens.size(); ++i) {
current = problem.costFunction(gens.get(i));
if (max < current) {
max = curr... | 9 |
@Override
public void draw(Graphics g) {
g.setColor(Color.WHITE);
g.setFont(new Font("Tahoma", Font.PLAIN, FONT_SIZE - FONT_SIZE/4));
switch (type) {
case 0:
g.drawString("T", x, y);
break;
case 1:
g.drawString("+", x, ... | 3 |
private int indOfOutP( char op, String equ ){
int PDepth = 0;
for (int i = 0; i < equ.length(); i++){
if (equ.charAt(i) == '(')
PDepth++;
else if (equ.charAt(i) == ')')
PDepth--;
else if (PDepth == 0){
if (equ.charAt(i) == op)
return i;
}
}
return -1;
} | 5 |
public String typeConveter(byte val)
{
String rString = "?";
switch(val)
{
case STRING:
rString = "String";
break;
case HIT_TEST:
rString = "Hit Test";
break;
case SHIP:
rString = "Ship";
break;
case SHIPKILLED:
rString = "Ship Killed";
break;
case SH... | 8 |
protected static int getNPrime(int n) {
if (n == 1) return FIRST_PRIME;
if (n == 2) return SECOND_PRIME;
int prime = SECOND_PRIME;
int count = 2;
for (int i : primesByOrder.keySet()) {
if (n > i) {
count = i;
prime = primesByOrder.get(... | 8 |
public int getNewPosition() {
return this.newPosition;
} | 0 |
public Evaluator(String expression){
Stack<Expression> expressionStack = new Stack<Expression>();
for (String token : expression.split(" ")){
if (token.equals("+")) {
Expression subExpression = new Plus(expressionStack.pop(), expressionStack.pop());
expressionStack.push(subExpression);
} else if (toke... | 3 |
private String serverRecievedSendFrame(SendFrame msg){
String reply= "";
if (msg.getMessage().equals("stats\n"))
Statistics.getStatisticsObject().getStats();
else if (msg.getMessage().equals("stop\n"))
_cH.stopServer();
else if (msg.getMessage().equals("clients online\n"))
reply= _users.getListOfAllUse... | 4 |
protected boolean canEnter(Tile t) {
if (t == init || t == destination) return true ;
return t.habitat().pathClear && (
t.owner() == null ||
t.owner().owningType() < priority
) ;
} | 4 |
Subsets and Splits
SQL Console for giganticode/java-cmpx-v1
The query retrieves a limited number of text entries within a specific length range, providing basic filtering but minimal analytical insight.