text stringlengths 14 410k | label int32 0 9 |
|---|---|
@Override
public void keyTyped(KeyEvent event) {
char ch = event.getKeyChar();
if (ch == '\n' || ch == '\r') {
if (canOpenSelection()) {
openSelection();
}
event.consume();
} else if (ch == '\b' || ch == KeyEvent.VK_DELETE) {
if (canDeleteSelection()) {
deleteSelection();
}
event.consum... | 6 |
public void solve(char[][] board) {
if (board == null || board.length == 0 || board[0].length == 0) {
return;
}
int length = board[0].length - 1;
int height = board.length - 1;
for (int i = 0; i < length; i++) {
fill(board, 0, i);
fill(board, height, length - i);
}
for (int j = 0; j < height; j++... | 9 |
@Override
public Program mutate(Program program) throws InvalidProgramException {
if (!(program instanceof ProgramImpl)) {
throw new InvalidProgramException();
}
Random randomGenerator = new Random();
ProgramImpl program1 = (ProgramImpl) program.clone();
List<Reaction> reactions = program1.getReactions();... | 4 |
public String update(String string, String string2) {
// TODO Auto-generated method stub
for (int i = 0; i < clientObj.length; i++) {
if((clientObj[i].getPassword()).equals(string)){
clientObj[i].setEmail(string2);
return clientObj[i].getEmail();
}
}
return null;
} | 2 |
public OptionsPanel(Handler handler, boolean optioncollapsed, int random) {
super();
if(random == 0) color = "_green";
else if(random == 1) color = "_blue";
else color = "_orange";
this.setLayout(new MigLayout("fill"));
this.setBackground(Color.black);
JPanel t... | 7 |
public void AllPairsShortestPath(int[][] matrix) {
int numberVertices = matrix.length;
// create new storage container for path and weight information
pathWeights = new int[numberVertices][numberVertices];
// Initialise containers;
for (int i = 0; i < numberVertices; i++) {
for (int j = 0; j... | 8 |
public boolean matches(String word) {
if (word.length() != string.length()) {
return false;
}
for (int i=0; i<word.length(); i++) {
if (string.charAt(i) != ANY_CHAR && string.charAt(i) != word.charAt(i)) {
return false;
}
}
return true;
} | 4 |
public void tilesetLaden(BufferedImage set){
tiles = new ArrayList<Tile>();
int Anzahl_x = set.getWidth()/32;
int Anzahl_y = set.getHeight()/32;
for(int x=0;x<Anzahl_x;x++){
for(int y=0;y<Anzahl_y;y++){
Tile t = new Tile((set.getSubimage(x*32, y*32, 32, 32)));
/*index
* 0 gras
* 1 ... | 2 |
public static Integer[][] crossover(Integer[] parent1, Integer[] parent2)
{
Integer[] child1 = new Integer[matrixSize] ;
Integer[] child2 = new Integer[matrixSize] ;
Integer[][] result = new Integer[2][matrixSize] ;
int i = 0, parent1Pos = 0, parent2Pos = 0 ;
... | 6 |
public void put(long key, E value) {
int i = ContainerHelpers.binarySearch(mKeys, mSize, key);
if (i >= 0) {
mValues[i] = value;
} else {
i = ~i;
if (i < mSize && mValues[i] == DELETED) {
mKeys[i] = key;
mValues[i] = value;
... | 7 |
public static void defineEnemies(int level){
enemyDim.clear();
enemyDim.put("skeleton", new int[]{26, 46});
try {
skeleton.add(ImageIO.read(CharacterManager.class.getClassLoader().getResourceAsStream("images/Skeleton1.png")));
skeleton.add(ImageIO.read(CharacterManager.class.getClassLoader().getResourceAsSt... | 1 |
private void loadGUIFromOperator() {
String code = operator.getCode();
String filialCode = operator.getFilialCode();
String firstName = operator.getFirstName();
String surName = operator.getSurName();
String parentName = operator.getParentName();
String password = operator.getPassword();
Boolean contr... | 9 |
@Override
public void deserialize(Buffer buf) {
id = buf.readShort();
if (id < 0)
throw new RuntimeException("Forbidden value on id = " + id + ", it doesn't respect the following condition : id < 0");
finishedlevel = buf.readShort();
if (finishedlevel < 0 || finishedlevel... | 3 |
@Override
protected List<CharPoint> getNeighbors(CharPoint field) {
List<CharPoint> neighbors = new ArrayList<CharPoint>(this.neighbors.length);
int x = field.getX();
int y = field.getY();
for (int xx = x - 1; xx <= x + 1; xx++) {
for (int yy = y - 1; yy <= y + 1; yy++) {
if (xx == x && yy == y)
co... | 8 |
public ChatChannel[] getAllChatChannels(){
ChatChannel channels[] = null;
try {
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
String url = "jdbc:derby:" + DBName;
Connection connection = DriverManager.getConnection(url);
Statement statement = connection.createStatement();
String sqlState... | 2 |
public int accessMemVictimCache(int smpIndexFrom, int numCPUFrom, int smpIndexTo, int numCPUTo, int cacheIndex, int startTime){
int n = getNumberSyncObjectsUntil(smpIndexTo);
SMPNodeConfig smpNodeCfg=Configuration.getInstance().smpNodeConfigs.get(smpIndexTo);
n+=1+smpNodeCfg.cacheConfigsPT.size();
if(smpNodeCfg... | 7 |
public Main_Window() {
// TODO Auto-generated constructor stub
final JFrame main_frame = new JFrame("stt");
main_frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JScrollPane content = new JScrollPane();
//content.setLayout(new FlowLayout());
main_frame.add(content);
source_code.setBorder(BorderFacto... | 3 |
public int compareTo(Point o) {
if (getX() < o.getX()) {
return -1;
} else if ((getX() == o.getX()) && (getY() == o.getY())) {
return 0;
} else if ((getX() == o.getX()) && (getY() < o.getY())) {
return -1;
}
return 1;
} | 5 |
private void calculerHeuresLivraison() throws HorsPlageException {
int tempsSecondes;
List<Troncon> listTroncons;
PlageHoraire plage = null;
Calendar heureDebut = Calendar.getInstance();
double vitesseKmH=0;
for(Chemin chemin : this.getCheminsResultats()) {
... | 6 |
public StackFrame()
{
// first create the buttons and widgets to put on the frame
pushButton = new JButton("Push Item");
popButton = new JButton("Pop Item");
peekButton = new JButton("Peek At Stack");
showButton = new JButton("Show Stack");
sizeButton = new JButton("... | 9 |
public boolean isAnyKindOfOfficer(Law laws, MOB M)
{
if((M.isMonster())
&&(M.location()!=null)
&&(CMLib.flags().isMobile(M)))
{
if((laws.officerNames().size()<=0)
||(laws.officerNames().get(0).equals("@")))
return false;
for(int i=0;i<laws.officerNames().size();i++)
{
if((CMLib.english().co... | 8 |
public double getVitality() {
return vitality;
} | 0 |
public void setTool(int tool) {
hp.setTool(tool);
if(tool == 0) {
pencil.setSelected(true);
} else if(tool == 1) {
fill.setSelected(true);
} else if(tool == 2) {
chooser.setSelected(true);
} else if(tool == 3) {
line.setSelected(true);
}
curTool = tool;
} | 4 |
public String readUntil(char c) throws IOException {
if (lookaheadChar == UNDEFINED) {
lookaheadChar = super.read();
}
line.clear(); // reuse
while (lookaheadChar != c && lookaheadChar != END_OF_STREAM) {
line.append((char) lookaheadChar);
if (lookahea... | 4 |
public tile searchMap(TriPoint t){
tile Tile = new tile(t);
for(int i = 0; i < tiles.size(); i++){
Tile = tiles.get(i);
if(t.x == Tile.coords.x){
if(t.y == Tile.coords.y){
return Tile;
}
}
}
return... | 3 |
protected void end() {} | 0 |
static void destroy() {
while (! queue.isEmpty()) {
try {
ProxyConnection conn = queue.take();
if (conn != null && conn.isValid(DB_ISVALID_TIMEOUT)) {
conn.reallyClose();
}
} catch (InterruptedException | SQLException ex... | 4 |
public void setLines(ArrayList<PathItem> lines) {
this.lines = lines;
} | 0 |
public boolean export(String filename){
try {
StringBuilder sb = new StringBuilder();
sb.append(frozen).append('\n');
int i = layers.size();
for (Node[] layer: layers){
//Account for bias weights
int layer_size = layer.length;
if (--i != 0) layer_size--;
sb.append(layer_size).append('\t');... | 6 |
private static int decode4to3(
final byte[] source, final int srcOffset,
final byte[] destination, final int destOffset, final int options ) {
// Lots of error checking and exception throwing
if( source == null ){
throw new NullPointerException( "Source array was null." );
}... | 8 |
public ConfigGetDb(String fileName)
{
FileInputStream inputFile = null;
try
{
inputFile = new FileInputStream(fileName);
} catch (FileNotFoundException e)
{
System.out.println(fileName + ":" + e);
e.printStackTrace();
}
Properties props = new Properties();
InputStream in = new Buff... | 2 |
@Override
protected void readCacheSelf(Element e) throws ProblemsReadingDocumentException {
for (String key: Arrays.asList(XMLCacheDataKeys)) {
String value = e.getAttributeValue(key);
if (value==null)
value = ""; // keep existing value of same name if possible
setProperty(key,value);
}
} | 2 |
public static String checkForCacheUpdates(boolean verbose, String currentVersion, JSONObject versionsConfig) {
if (Util.versionIsEquivalentOrNewer(currentVersion, versionsConfig.get("latestcache").toString())) {
//Jump out if the launcher is up to date
Logger.info("... | 7 |
public void dumpInstruction(TabbedPrintWriter writer)
throws java.io.IOException {
boolean needBrace = thenBlock.needsBraces();
writer.print("if (");
cond.dumpExpression(writer.EXPL_PAREN, writer);
writer.print(")");
if (needBrace)
writer.openBrace();
else
writer.println();
writer.tab();
thenBl... | 8 |
public static void main(String[] args)
{
String str = null;
System.out.println(str.length());
} | 0 |
public void resizeMap(int newWidth, int newHeight, int widthOffset, int heightOffset) {
setMapWidth(newWidth);
setMapHeight(newHeight);
HashMap<Point, Tile> newMap = new HashMap<Point, Tile>();
for (Point p : tileMap.keySet()) {
Tile t = tileMap.get(p);
short newX = (short) (p.getX() + widthOffset);... | 5 |
@After
public void tearDown() {
try
{
AqWsFactory.close(clientProxy);
}
catch(Exception ex)
{
fail("tearDown failed: " + ex.toString());
}
} | 1 |
@Override
protected void onKick(String channel, String kickerNick, String kickerLogin, String kickerHostname, String recipientNick, String reason)
{
super.onKick(channel, kickerNick, kickerLogin, kickerHostname, recipientNick, reason);
int targettab = 0;
int i = 0;
while(true)
{
try
{
if(Main.gui... | 4 |
public void buildTrie(Set<String> col) {
for (String str : col) {
Trie[] trieArray = sons;
for (int i = 0; i < str.length(); ++i) {
Trie tmpTrie;
if (trieArray[str.charAt(i) - 'a'] == null) {
tmpTrie = new Trie();
tmpTrie.ch = str.charAt(i);
trieArray[str.charAt(i) - 'a'] = tmpTri... | 4 |
private final boolean vowelinstem()
{ int i; for (i = 0; i <= j; i++) if (! cons(i)) return true;
return false;
} | 2 |
public void setIdSolicitud(int idSolicitud) {
this.idSolicitud = idSolicitud;
} | 0 |
public void raiseSalary(double byPercent)
{
double raise = salary * byPercent / 100;
salary += raise;
} | 0 |
public boolean CanBePickedUp(Item item) {
switch (direction) {
case DIR_UP:
if (mazeHeight == 1) {
return false;
}
mazeHeight--;
break;
case DIR_DOWN:
mazeHeight++;
break;
... | 6 |
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
User other = (User) obj;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
retur... | 6 |
* @return a List of the matching meetings
*
*/
private List<Meeting> listForContact(Set<Meeting> meetingSet, Contact contact)
{
List<Meeting> list = new ArrayList<Meeting>();
for(Meeting meeting : meetingSet)
{
if(meeting.getContacts().contains(contact))
{
list.add(meeting);
}
}
return ... | 2 |
public void drawCoordinateSystem(Graphics g) {
g.setColor(Color.lightGray);
g.drawLine(0, startY, PLOT_WIDTH, startY);
g.drawLine(startX, 0, startX, PLOT_HEIGHT);
for (int x = startX - (int) zoom; x > zoom; x -= (int) zoom) {
String num = "" + (x - startX) / (int) zoom;
g.drawString(num, x, startY);
}
... | 6 |
public MixinProxy(TwoTuple<Object, Class<?>>... pairs) {
delegatesByMethod = new HashMap<String, Object>();
for(TwoTuple<Object, Class<?>> pair : pairs) {
for(Method method : pair.second.getMethods()) {
String methodName = method.getName();
// The first interf... | 5 |
public static boolean isField(Member m) {
return (m instanceof Field) || ((m instanceof LocalField)
&& !(m instanceof LocalMethod));
}; | 2 |
public static void main(String [] args){
buildOptions();
buildUI();
//scoreBoard.setHighScore(0);
//scoreBoard.setHighScore(0);
while(true) {
if(theRedButton ) {
score = 0;
wins = 0;
streak = true;
optionsDone = false;
theRedButton = false;
}
if(optionsDone && streak) {
setu... | 8 |
@SuppressWarnings("static-method")
protected String getData(Row row, Column column, boolean nullOK) {
if (row != null) {
String text = row.getDataAsText(column);
return text == null ? nullOK ? null : "" : text; //$NON-NLS-1$
}
return column.toString();
} | 3 |
public static void main(String[] args){
try{
BufferedReader in=null;
if(args.length>0){
in = new BufferedReader(new FileReader(args[0]));
}
else{
in = new BufferedReader(new InputStreamReader(System.in));
}
ArrayList<String> input = new ArrayList<String>();
String inp = in.readLine();
... | 6 |
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 Optgroup(HtmlMidNode parent, HtmlAttributeToken[] attrs){
super(parent, attrs);
for(HtmlAttributeToken attr:attrs){
String v = attr.getAttrValue();
switch(attr.getAttrName()){
case "disabled":
disabled = Disabled.parse(this, v);
break;
case "label":
label = Label.parse(this, v);... | 3 |
public void closure(Production p){
System.out.println("------------------------- Closure " + p.toString()+ " ------------------------------");
State s = new State();
List<Production> prList = new ArrayList<>();
prList.add(p);
for(int i = 0; i < prList.size(); i++){
Production prod = prList.get(i);... | 9 |
public static boolean isPrime(int i) {
if (i < 2) {
return false;
} else if (i % 2 == 0 && i != 2) {
return false;
} else {
for (int j = 3; j <= Math.sqrt(i); j = j + 2) {
if (i % j == 0) {
return false;
... | 5 |
@Override
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
if (kirjaudutaankoUlos(request)) {
kirjauduUlos(request, response);
} else if (... | 8 |
public void displayStory() {
for (String[] akt : fressakte) {
Leckerbissen l1 = find(akt[0]);
Leckerbissen l2 = find(akt[1]);
if (l1 == null || l2 == null) {
System.err.println("Fressakt konnte nicht ausgeführt werden: " + akt[0] + " frisst " + akt[1]);
}
if (!(l1 instanceof Fisch)) {
Syste... | 8 |
private void setUpGeneralGraphData() {
bars = setUpBars(Database.statistics.get(categoryId).histogram);
for (Entry<Float, float[][]> allData : Database.DB_ARRAY.entrySet()) {
// get all company data (all 87 pts) for each collected set
timeSeriesCompayData.put(allData.getKey(), allData.getValue()[id]);//
}... | 1 |
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 void fillIt() {
while (index != -1) {
cur = pixels[index];
--index;
if (cur.y + 1 < bim.getHeight()
&& bim.getRGB(cur.x, cur.y + 1) == old) {
bim.setRGB(cur.x, cur.y + 1, fill);
++index;
pixels[index] = new Point(cur.x, cur.y + 1);
}
if (cur.y - 1 >= 0 && bim.getRGB(cur.x, cur.y... | 9 |
public void exitGroup()
{
Object root = model.getRoot();
Object current = getCurrentRoot();
if (current != null)
{
Object next = model.getParent(current);
// Finds the next valid root in the hierarchy
while (next != root && !isValidRoot(next)
&& model.getParent(next) != root)
{
next = mo... | 7 |
public JPanelMainFrameHeader() {
super();
try {
GUIImageLoader imgLdr = new GUIImageLoader();
biHeader = imgLdr.loadBufferedImage(GUIImageLoader.GREEN_MAINFRAME_HEADER);
} catch (Exception e) {
e.printStackTrace();
}
} | 1 |
public static void saveLifestone(String bWorld, int bX, int bY, int bZ) throws SQLException {// Block
// block
String table = Config.sqlPrefix + "Lifestones";
Connection con = getConnection();
PreparedStatement statement = null;
int success = 0;
String query = "select * from " + tab... | 3 |
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
String folderPath=null;
String fileName=null;
Writer writer=response.getWriter();
List<FileItem> items;
System.out.println("In FilesReciveServlet");
try... | 9 |
private boolean checkCondition(Map<String, String> conditionMap,
List<ConditionBean> list) {
boolean flag = true;
for (ConditionBean conditionBean : list) {
if (conditionMap.containsKey(conditionBean.getId())
&& conditionBean.getValue().equals(ALL)) {
continue;
}
if (!conditionMap.containsKey(... | 6 |
@Override
public void keyPressed(KeyEvent e)
{
map.keyPressed(e);
switch (e.getKeyCode())
{
// Floor changes. Not handled here, but tracked for re-painting:
case KeyEvent.VK_PAGE_UP:
case KeyEvent.VK_PAGE_DOWN:
... | 9 |
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jScrollPane3 = new javax.swing.JScrollPane();
jEditorP... | 0 |
public void testConstructor_ObjectStringEx2() throws Throwable {
try {
new MonthDay("T10:20:30.040+14:00");
fail();
} catch (IllegalArgumentException ex) {
// expected
}
} | 1 |
public int[] getTouchingVoxel( int x, int y, int z ) throws UnsupportedOperationException
{
switch ( this )
{
case LEFT:
return new int[] { x - 1, y, z };
case RIGHT:
return new int[] { x + 1, y, z };
case BOTTOM:
... | 6 |
public boolean equals( Object other ) {
if ( ! ( other instanceof TObjectFloatMap ) ) {
return false;
}
TObjectFloatMap that = ( TObjectFloatMap ) other;
if ( that.size() != this.size() ) {
return false;
}
try {
TObjectFloatIterator ite... | 8 |
public NSDictionary createDay(Date date,
String name,
List<NSDictionary> events){
NSDictionary day = new NSDictionary();
day.put("date", date);
day.put("name", name);
Integer i = 0;
for (NSDictionary nsd: events){
day.put("events" + Integer.toString(i), nsd);
i++;
}
return day;
... | 1 |
public void setSocketOption(byte option, int value) throws IllegalArgumentException, IOException {
switch(option){
case SocketConnection.DELAY:
socket.setTcpNoDelay(option == 0);
break;
case SocketConnection.KEEPALIVE:
socket.setKeepAlive(option != 0);
... | 5 |
@Override
public void e(float sideMot, float forMot) {
if (this.passenger == null || !(this.passenger instanceof EntityHuman)) {
super.e(sideMot, forMot);
this.W = 0.5F; // Make sure the entity can walk over half slabs,
// instead of jumping
return;
}
EntityHuman human = (EntityHuman) this.passe... | 8 |
private void createRooms() {
HashSet<String> roomPaths;
try {
roomPaths = KvReader.getKvFiles("./rooms");
} catch (IOException e){
e.printStackTrace(System.err);
return;
}
for (String s : roomPaths) {
HashMap<String, String> roomAtt... | 3 |
private void jMsgRActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMsgRActionPerformed
jTable1.getColumnModel().getColumn(0).setCellRenderer(new CustomCellRender_Message());
jTable1.setModel(modele);
jTable1.setAutoCreateRowSorter(true);
Color c = new Color(63... | 2 |
@Override
public String toString() {
return "Chunck at "+xPos+" "+zPos+" in "+parent.toString();
} | 0 |
private static void printEllipsisRow(int width, int printWidth,
int startX) {
System.out.print("|");
if (startX > 0) // Print an extra column of "..."s at the beginning.
System.out.print("...,");
for (int x = 0; x < printWidth; x++)
System.out.print(" ... ");
if (printWidth < width)... | 3 |
public boolean evaluateDarkCheckmate(Chessboard boardToCheck)
{
Chessboard chessboardCopy = new Chessboard(boardToCheck);
Tile[][] tileBoardCopy = chessboardCopy.getBoard();
boolean isInCheckmate = false;
ArrayList<Piece> offendingPieces = new ArrayList<>();
ArrayList<Location> safeAreas = new ArrayList<>... | 9 |
public Select cache(Boolean cache) {
if (cache == null) {
this.cache = null;
return this;
}
if (cache)
this.cache = Cache.SQL_CACHE;
else if (!cache)
this.cache = Cache.SQL_NO_CACHE;
return this;
} | 3 |
public HysteresisThresholdDialog(final Panel panel){
setTitle("Hysteresis Threshold");
setBounds(1, 1, 250, 220);
Dimension size = getToolkit().getScreenSize();
setLocation(size.width/3 - getWidth()/3, size.height/3 - getHeight()/3);
this.setResizable(false);
setLayout(null);
JPanel pan1 = new JPanel();
... | 2 |
public static void save(String filename) {
File file = new File(filename);
String suffix = filename.substring(filename.lastIndexOf('.') + 1);
// png files
if (suffix.toLowerCase().equals("png")) {
try { ImageIO.write(onscreenImage, suffix, file); }
catch (IOExcep... | 4 |
public static void writeLargeFile(){
(new Thread() {
public void run() {
for (int i = 1; i <= 10; i++) {
StringBuffer sb = new StringBuffer();
for (int j = 0; j < 100000; j++) {
sb.append("chris");
}
FileProcess.write("demo" + i + ".txt", sb.toString());
}
}
}).start();
} | 2 |
public static void main(String[] args) {
Cube cube;
if (args.length <= 0) {
cube = new Cube("input/valid_input1.txt");
} else {
cube = new Cube(args[0]);
}
Boolean validCube = Cube.verifyCube(cube.state);
if (validCube) {
boolean verbose = false;
if (args.length > 1) {
verbose = Boolean.pars... | 3 |
@Override
public void keyReleased(KeyEvent arg0) {
int code = arg0.getKeyCode();
if(code < 0 || code >= keys.length)return;
keys[code] = false;
} | 2 |
public GlyphText addText(String cid, String unicode, float x, float y, float width) {
// keep track of the text total bound, important for shapes painting.
// IMPORTANT: where working in Java Coordinates with any of the Font bounds
float w = width;//(float)stringBounds.getWidth();
flo... | 4 |
private void newServer() {
// status
BTServerStateListener serverStateListener = new BTServerStateListenerImpl(
serverUI);
// recv
BTObservableHandlerListenerImpl handlerListener = new BTObservableHandlerListenerImpl(
serverUI);
BTObservableHandlerFactory handlerFactory = new BTObservableHandlerFact... | 1 |
public double getFruitProbs(int pos, int fruits, int score)
{
double prob = 0.0, innerprob, curprob;
if(pos == length - 1)
{
if(fruits <= distribution[pos] && score == fruits)
prob = 1.0;
}
else
{
for(int i = 0, s = 0; (i <= fruits) && (s <= score) && (i <= distribution[pos]); i++, s = s + (len... | 8 |
private Node putRoot(Node x, Key key, Value value)
throws DuplicateKeyException {
if (x == null)
return new Node(key, value, 1);
int cmp = key.compareTo(x.key);
if (cmp == 0)
throw new DuplicateKeyException();
else if (cmp < 0) {
x.left = putRoot(x.left, key, value);
x = rotateRight(x);
} else ... | 4 |
public void update(long delta) {
time += delta;
if (time > nextFruitTime && !stopped) {
nextFruitTime = rate.getTime();
time = 0;
Transform3D t3dOffset = new Transform3D();
int x = rand.nextInt(xGridCount);
int y = rand.nextInt(yGridCount);
t3dOffset.setTranslation(new Vector3d(xgrid[x][y], yg... | 4 |
public Map<String, String> userJobList(int uid) {
Map<String, String> jobList = new HashMap<String, String>();
// fetch related data from database
String sql = "select u_clubs,u_clubs_level from user where uid=" + uid;
// parse the data
Map<?, ?> map = (Map<?, ?>) (Object) querySql(sql).get(0);
String clubD... | 9 |
private static PrinterResolution extractFromResolutionString(String buffer) {
if (buffer != null && buffer.length() > 0) {
int sep = buffer.indexOf('x');
int x;
int y;
if (sep != -1 && sep < buffer.length() - 1) {
x = Numbers.getInteger(buffer.substring(0, sep), 0);
y = Numbers.getInteger(buffer.... | 6 |
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
int a = e.getWheelRotation();
if (a < 0) {
for(int i = 0; i < -a; i++) {
keys[KeyEvent.VK_UP] = true;
updateStatus();
keys[KeyEvent.VK_UP] = false;
... | 4 |
@Override
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
if (args.length==0) {
String[] text = new String[] {
"§a§lJoin a team",
"§9§lBLUE §8- §e§l"+Blue.getSize(),
"§a§lGREEN §8- §e§l"+ Green.getSize(),
... | 6 |
public void stopDecryptingHands() {
try {
decryptSub.remove();
decryptionCount = 0;
} catch (Exception e) {
// do nothing
}
decryptSub = null;
} | 1 |
private static DataSet[][][] aggregateTraces(String[] nodeClasses,
String[] approaches, String[] metrics) {
DataSet[][][] allData = new DataSet[nodeClasses.length][approaches.length][metrics.length];
for(int i = 0; i < nodeClasses.length; i++) {
// VirtuaTraces
... | 9 |
public void play(Channel c) {
if (!active(GET, XXX)) {
if (toLoop)
toPlay = true;
return;
}
if (channel != c) {
channel = c;
channel.close();
}
// change the state of this source to not stopped and not paused:
stopped(SET, false);
paused(SET, false);
} | 3 |
private static void playres(Resource res) {
Collection<Resource.Audio> clips = res.layers(Resource.audio);
int s = (int)(Math.random() * clips.size());
Resource.Audio clip = null;
for(Resource.Audio cp : clips) {
clip = cp;
if(--s < 0)
break;
}
play(clip.clip);
} | 2 |
public static DelayCodeEnum fromValue(String v) {
for (DelayCodeEnum c: DelayCodeEnum.values()) {
if (c.value.equals(v)) {
return c;
}
}
throw new IllegalArgumentException(v);
} | 2 |
ArrayList<Stack<String>> join(boolean[][] res, int begin, String s,
HashMap<Integer, ArrayList<Stack<String>>> dp) {
int n = s.length();
ArrayList<Stack<String>> resArr = new ArrayList<Stack<String>>();
if (begin == n) {
resArr.add(new Stack<String>());
return resArr;
}
if (dp.containsKey(begin))
... | 5 |
private void calculateBalance(){
int[] rowWeights = ((CargoLifter) getWorld()).getRowWeights();
int weightTop = 0;
int weightBottom = 0;
weightDifference = 0;
for(int i = 0; i < rowWeights.length / 2; i++)
weightTop += rowWeights[i];
for(int ... | 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.