text stringlengths 14 410k | label int32 0 9 |
|---|---|
public static void validateUsername(String username) throws ProtocolException {
if(username.length() < 3){
throw new ProtocolException("Username too short: needs to be 3 characters or longer.");
}
if(username.length() > 16){
throw new ProtocolException("Username too long: needs to be 16 characters or less.... | 3 |
static boolean haveImage (int w, int h, Color c, int ox, int oy, int d)
{ if (StaticImage==null) return false;
return (w==W && h==H && ox==Ox && oy==Oy && D==d && C.getRGB()==c.getRGB());
} | 6 |
public static Cons yieldInCursorClauses(Cons intree, boolean dontoptimizeP, Object [] MV_returnarray) {
{ Stella_Object vartree = intree.rest.value;
Symbol keyvar = null;
Symbol valuevar = null;
Surrogate collectionbasetype = null;
{ Stella_Object collectiontree = null;
StandardObje... | 8 |
public boolean refreshStatus() {
// - Get the status
Icon icon;
String info = null;
switch (lfs.getStatus()) {
case LessFileStatus.UP_TO_DATE:
icon = OK;
break;
case LessFileStatus.ERROR:
icon = ERROR;
break;
case LessFileStatus.UNKNOWN:
case LessFileStatus.PROCESSING:
icon = WAIT;
bre... | 7 |
@Override
public int allocateClusters(int tailCluster, int count) throws IOException {
int headCluster = -1;
int tailOffset = tailCluster;
while (count > 0 && freeListHead >= 0) {
int fatEntry = fs.getFatEntry(freeListHead);
if ((fatEntry & CLUSTER_STATUS) == CLUSTER_... | 9 |
@Override
public void run(){
Scanner sc = new Scanner(System.in);
ArrayList<MenuItem> menu = menuManager.getMenu();
while(true){
System.out.print("1. Add New Alacarte to Menu \n"
+ "2. Add New Set to Menu\n3. Delete MenuItem from the Menu\n4. Update the Alacar... | 7 |
private String createAuction() {
if (user.isOnline()) {
int duration = 0;
String describtion = "";
try {
duration = Integer.parseInt(stringParts[1]);
if (duration <= 0) {
return "Error: The duration has to be > 0!";
}
for (int i = 2; i < stringParts.length; i++) {
desc... | 9 |
@Override
public boolean execute(final MOB mob, List<String> commands, int metaFlags)
throws java.io.IOException
{
if(mob.soulMate()!=null)
dispossess(mob,CMParms.combine(commands).endsWith("!"));
else
if(!mob.isMonster())
{
final Session session=mob.session();
if(session!=null)
{
if((sessio... | 9 |
public List<?>[] getStates()
{
ArrayList<Integer> ids = new ArrayList<Integer>();
ArrayList<TaggedStorageChunk> chunks = new ArrayList<TaggedStorageChunk>();
try
{
DataInputStream in = new DataInputStream(new ByteArrayInputStream(data));
int size = in.readInt(... | 5 |
protected void processSingleClick(MouseEvent e) {
Node node = textArea.node;
JoeTree tree = node.getTree();
if (e.isShiftDown()) {
tree.selectRangeFromMostRecentNodeTouched(node);
} else if (e.isControlDown()) {
if (node.isSelected() && (tree.getSelectedNodes().size() != 1)) {
tree.removeNodeFromSe... | 6 |
public static String formatName(String name) {
if (name.length() > 0) {
char characters[] = name.toCharArray();
for (int c = 0; c < characters.length; c++)
if (characters[c] == '_') {
characters[c] = ' ';
if (c + 1 < characters.length && characters[c + 1] >= 'a'
&& characters[c + 1] <= 'z')... | 8 |
private void spellCheck() {
String word = this.currentWord.toString();
if (!word.equals("")
&& SpellChecker.getInstance().isMisspelled(word)) {
if (this.spllingErrorHandler != null) {
this.spllingErrorHandler
.handleSpellingError(this.currentWord.toString(),
this.uiGlyphs
.toAr... | 3 |
public Tree orExpressionPro(){
Tree firstConditionalExpression = null, secondConditionalExpression = null;
Symbol operator = null;
if((firstConditionalExpression = andExpressionPro()) != null){
if((operator = accept(Symbol.Id.PUNCTUATORS,"\\|\\|")) != null){
if((secondConditionalExpression = orExpressio... | 3 |
public void addQLDropTargets(DropTargetFactory dtf){
for(JButton btn : quick_btns){
btn.setDropTarget(dtf.makeDropTarget());
}
} | 1 |
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void collecter(APreprocessingEngine aPPEngine) {
try {
File[] lesFichiers = repertoireInput.listFiles();
if (lesFichiers != null) {
for (int i = 0; i < lesFichiers.length; i++) {
String leContenu = new String();
BufferedReader reade... | 6 |
public void setSpeech(String speech) {
this.speech = speech;
} | 0 |
public static void readCSVFile(String path, String csvSplitBy) {
BufferedReader read;
String line;
try {
read = new BufferedReader(new FileReader(path));
while ((line = read.readLine()) != null) {
String[] data = line.split(csvSplitBy);
Que... | 3 |
public static void main(String[] args) throws JSONException {
/* Thread t = new Thread();
t.start();*/
for(int i=1;i<10000;){
JSONArray data = getData(i);
String res = data.getString(0);
JSONObject o = new JSONObject(res);
//System.out.println(o);
JSONObject o1 = new JSONObjec... | 2 |
public void reapply(){
if( factory != null ){
factory.setDiagram( view.getDiagram() );
}
} | 1 |
@Override
public double execute(Date start, Date end) {
int duration = TimeCalculator.duration(start, end);
duration = duration % this.minuteUnit > 0 ? (duration / this.minuteUnit + 1)
: duration / this.minuteUnit;
double price = 0;
if (duration == 1) {
price = this.firstMinutePrice;
} else if (durati... | 4 |
public static void main(String[] args) {
int[][] adjacencyMatrix;
Scanner in = new Scanner(System.in);
// get first line and get the number of cases to test.
int caseCount = Integer.parseInt(in.nextLine());
int loopCount = 0;
while (caseCount - loopCount > 0) {
String line = in.nextLine(... | 7 |
public double value()
{
ArrayList<Object> argsValues = new ArrayList<Object>();
for (Block arg: args)
{
argsValues.add(arg.value());
}
try
{
return (Double) method.invoke(null, argsValues.toArray());
} catch (IllegalArgumentException e) {
} catch (Illegal... | 4 |
public ResultSet queryResult(String query) {
final Connection connection = getConnection();
try {
if (connection == null) {
Utilities.outputError("Could not connect to database '" + m_databaseName + "'");
return null;
}
if (m_statement != null) {
m_statement.close();
m_statement ... | 5 |
private void doEditUser(HttpServletRequest request, HttpServletResponse response,boolean isEditUser) throws ServletException, IOException {
String userId = StringUtil.toString(request.getParameter("userId"));
if(!StringUtil.isEmpty(userId)) {
User user = null;
try... | 3 |
private Image getImage(String filename) {
// to read from file
ImageIcon icon = new ImageIcon(filename);
// try to read from URL
if ((icon == null) || (icon.getImageLoadStatus() != MediaTracker.COMPLETE)) {
try {
URL url = new URL(filename);
... | 6 |
public void saveModel() {
try {
if (m_fileChooser == null) {
// i.e. after de-serialization
m_fileChooser =
new JFileChooser(new File(System.getProperty("user.dir")));
ExtensionFileFilter ef = new ExtensionFileFilter("model", "Serialized weka clusterer");
m_fileChooser... | 7 |
@Override
public void run() {
try {
//1. creating a server socket
providerSocket = new ServerSocket(2004, 10);
//2. Wait for connection
System.out.println("Waiting for connection");
connection = providerSocket.accept();
System.out.pri... | 4 |
public Tuple<GameCharacter, Item> battleMenu(GameCharacter hero) {
System.out.println("\n" + hero.getName() + "'s turn!");
System.out.println("1.) Attack somebody.");
System.out.println("2.) Use an item.");
System.out.println("3.) View your party.");
System.out.println("4.) View enemy party.");
int choic... | 8 |
public boolean needShuffle() {
if (count == 50)
return true;
else
return false;
} | 1 |
@Override
public TLValue evaluate() {
TLValue a = lhs.evaluate();
TLValue b = rhs.evaluate();
// number + number
if(a.isNumber() && b.isNumber()) {
return new TLValue(a.asDouble() / b.asDouble());
}
throw new RuntimeException("illegal expression: " + this);
} | 2 |
public static void deleteFile(File file)
{
if (file.isDirectory())
{
File[] children = file.listFiles();
if (children != null)
{
for (File child : children)
deleteFile(child);
}
children = file.listFiles();
if (children == nu... | 8 |
private void initialize() {
frmShowProduct = new JFrame();
textField_nr = new JTextField();
textArea_info = new JTextArea();
textField_nr.setHorizontalAlignment(SwingConstants.CENTER);
JButton btnShow = new JButton("show");
frmShowProduct.setTitle("Show Product");
frmShowProduct.setBounds(100, 100, 450, ... | 2 |
@Override
public HashMap<Integer, ArrayList<SamplePoint>> SpatialTemporalWindowQuery(long midTime, long tRadius, double longitude, double latitude, double sRadius) {
// TODO Auto-generated method stub
HashMap<Integer, ArrayList<SamplePoint>> result = new HashMap<>();
int segment... | 9 |
protected static void stopChatServer(Thread chatServerThread) {
while (chatServerThread.isAlive()) {
chatServerThread.interrupt();
log.info("INTERRUPT chat Server Thread");
try {
// this dummyClient is needed when chatServerThread
// is blocked in serverSocket.accept();
Socket dummyClient = new S... | 4 |
public Node checkISBNDel(Node temproot,int isbn){ //find the node(book object with ISBN
boolean b=false;
if(temproot!=null){
if(temproot.leftChld!=null || temproot.rightChld!=null)
parent=temproot; //keep the track of parent of current node
checkISBNDel(temproot.leftChld,isbn); // call recursively... | 6 |
public void deleteSelectedElements() {
for (Element element : selectedElements) {
// Place
if (element instanceof Place) {
((PetriNet) getGraph()).deletePlace(((Place) element).getName());
}
// Transition
if ... | 6 |
@GET
@Path("events/{id}")
@Produces({MediaType.APPLICATION_JSON })
public EventItf getEvent(@PathParam("id")int idEvent){
System.out.println("Return the event selected by the id");
return JpaTest.eventService.getEvent(idEvent);
} | 0 |
@Override
public ArrayList<Move> generateMovesForThisPiece(Chessboard chessboard) {
int toX = -1, toY = -1;
final ArrayList<Move> moves = new ArrayList<Move>();
final String positionPiece = chessboard.getPositionPiece(this);
final int getX = Helper.getXfromString(positionPiece);
final int getY = Helper.get... | 8 |
public Cons vizGetBinaryRelationsOf(LogicObject concept) {
{ VizInfo self = this;
{ MemoizationTable memoTable000 = null;
Cons memoizedEntry000 = null;
Stella_Object memoizedValue000 = null;
if (Stella.$MEMOIZATION_ENABLEDp$) {
memoTable000 = ((MemoizationTable)(OntosaurusU... | 6 |
public static boolean closedTermP(Stella_Object self) {
{ MemoizationTable memoTable000 = null;
Cons memoizedEntry000 = null;
Stella_Object memoizedValue000 = null;
if (Stella.$MEMOIZATION_ENABLEDp$) {
memoTable000 = ((MemoizationTable)(Logic.SGT_LOGIC_F_CLOSED_TERMp_MEMO_TABLE_000.surrog... | 7 |
public int[] checkPrime3(BigInteger n) {
char[] digits = n.toString().toCharArray();
int count0 = 0, count1 = 0, count2 = 0;
int[] c0 = new int[3], c1 = new int[3], c2 = new int[3];
int[] c5 = new int[1];
for (int i = 0; i < digits.length; i++) {
char c = digits[i];
... | 7 |
public RSInterface[] getSelectedChildren() {
RSInterface parent = getInterface();
RSInterface[] children = new RSInterface[parent.children.size()];
int count = 0;
for (int index = 0; index < children.length; index++) {
RSInterface child = RSInterface.getInterface(parent.children.get(index));
int childX = ... | 3 |
public static void main(String[] args) throws Exception {
String mfa = ConfigReader.getCHSDir() + File.separator +
"BroadTrees" + File.separator + "all76.mfa";
String classify = ConfigReader.getCHSDir() + File.separator +
"rbh" + File.separator + "GenomeToClass.txt";
String output = ConfigReader.getCHSD... | 8 |
private static void bigClosestDepotRouteWithUniformCut(Individual individual)
{
ProblemInstance problemInstance = Individual.problemInstance;
//Assign customer to route
boolean[] clientMap = new boolean[problemInstance.customerCount];
int assigned=0;
individual.bigRoutes = new ArrayList<ArrayList<ArrayLis... | 8 |
@Override
public void mouseDragged(MouseEvent e)
{
if (!e.isConsumed() && start != null)
{
int dx = e.getX() - start.x;
int dy = e.getY() - start.y;
Rectangle r = graphComponent.getViewport().getViewRect();
int right = r.x + ((dx > 0) ? 0 : r.width) - dx;
int bottom = r.y + ((dy > 0) ? 0 : r.heig... | 4 |
static String weekdag(int dag, int maand, int jaar) {
String dagVanDeWeek = "";
int getallenArray[] = {0,3,2,5,0,3,5,1,4,6,2,4};
int uitkomst;
if(maand < 3)
jaar--;
uitkomst = (jaar + jaar/4 - jaar/100 + jaar/400 +
getallenArray[maand - 1] + dag) % 7;
if(uitkomst == 0)
dagVanDeWeek = "zondag";
... | 8 |
public List<EmprestimoEstoque> pesquisarPorTodosOsDadosNaoNulos(EmprestimoEstoque emprestimoEstoque) {
List<EmprestimoEstoque> emprestimosEstoques = new LinkedList<>();
Connection connection = conexao.getConnection();
try {
String valorDoComandoUm = comandos.get("pesquisarPorTodosOsD... | 9 |
private static void loadChunkData(CompoundTag levelTag, short[][] sectionBlockIds, byte[][] sectionBlockData, boolean[] sectionsUsed, byte[] biomeIds) {
for (int i = 0; i < MAX_CHUNK_SECTIONS; i++) {
sectionsUsed[i] = false;
}
Tag biomesTag = levelTag.getValue().get("Biomes");
... | 9 |
@Override
public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel)
{
final MOB target=this.getTarget(mob,commands,givenTarget);
if(target==null)
return false;
if(target==mob)
return false;
if(!super.invoke(mob,commands,givenTarget,auto,asLevel))
return f... | 8 |
/* */ public void animate(Graphics g) {
/* 408 */ for (int i = 0; i < effects.size(); i++) {
/* 409 */ Effect e = (Effect)effects.get(i);
/* 410 */ e.update(17);
/* 411 */ if ((e.isElapsed()) || (!e.alive)) {
/* 412 */ effects.remove(i);
/* 413 */ e = null;
/* */ } ... | 3 |
@EventHandler(priority=EventPriority.HIGHEST)
public void onBlockPlace(BlockPlaceEvent event)
{
int iloscGildii = Bufor.iloscGildii;
if (iloscGildii != 0) {
for (int i = 0; i < iloscGildii;i++)
{
if (!(event.isCancelled())) {
String aktualnaGildia = Bufor.listaGildii.get(i);
... | 6 |
public static void main(String[] args) {
int solutionsCount = 0;
int maxSolutionsCount = -1;
int optimalPerimeter = -1;
for (int perimeter = 3; perimeter <= PERIMETER_MAX; ++perimeter) {
for (int i = 1; i < perimeter - 1; ++i) {
for (int j = i; j <= perimeter - i; ++j) {
for (int k = j; k <= perime... | 7 |
public void downloadUpdate() {
button.setEnabled(false);
downloader = new Thread(new Runnable() {
@Override
public void run() {
double size = updater.getFileSize("http://nazatar.bplaced.net/Mod/Unreal.jar/Unreal.jar");
Update.label_6.setText("" + s... | 4 |
public DisplayBoard clone()
{
DisplayBoard cloned = new DisplayBoard(width, height);
for(int x = 0; x < width; x++)
{
for(int y=0; y < height; y++)
{
cloned.grid[x][y] = grid [x][y];
cloned.colorGrid[x][y] = colorGrid[... | 2 |
void printHeader(String header) {
w.println("@T, \"" + header + "\"");
w.println(" " + DataIO.KEY_CREATED_AT + ", \"" + new Date() + "\"");
w.println(" " + DataIO.DATE_FORMAT + ", " + dfmt.toPattern());
String dig = System.getProperty("oms3.digest");
if (dig != null) {
... | 3 |
public Connection getConnection(){
return connection;
} | 0 |
public static void main(String[] args) {
int N = Integer.parseInt(args[0]);
// add elements 1, ..., N
StdOut.println(N + " random integers between 0 and 99");
DoublyLinkedList<Integer> list = new DoublyLinkedList<Integer>();
for (int i = 0; i < N; i++)
list.add((int... | 9 |
static Set<Point> rangePonints(Point from,int k,Map<String,Point> pointMap){
Set<Point> result=new HashSet<>();
for(int i=0;i<=k;++i){
collectPoint(pointMap,result,from,i,0);
collectPoint(pointMap,result,from,-i,0);
collectPoint(pointMap,result,from,0,i);
... | 1 |
public String[] getEquiv(String man)
{
ArrayList<String> matches = new ArrayList<String>();
for(String aMan : manus)
{
if(man.equals(aMan))
{
int i = manus.indexOf(aMan);
matches.add(numbers.get(i));
}
}
return matches.toArray(new String[0]);
} | 2 |
public double getPriceForQuantity( int quantity ) {
double price = 0;
for( Object object : orderList.toArray() ) {
Order order = (Order)object;
if( quantity > 0 ) {
if(quantity >= order.getQuantity()) {
price += order.getPrice();
quantity -= order.getQuantity();
} else if(quantity < orde... | 4 |
private static String sortCharacters(String string) {
if (string == null)
return null;
char[] array = string.toUpperCase().toCharArray();
char leftChar = 'A';
char rightChar = 'Z';
int index = 0;
int left = 0;
int right = array.length - 1;
// 13 passes at most
while (left < right) {
whi... | 8 |
@Override
protected void read(InputBuffer b) throws IOException, ParsingException {
VariableLengthIntegerMessage vLength = getMessageFactory().parseVariableLengthIntegerMessage(b);
b = b.getSubBuffer(vLength.length());
long length = vLength.getLong();
if (length < 0 || length > Options.getInstance().getInt("p... | 3 |
void parseDAS(DAS das) throws IOException {
Enumeration tableNames = das.getNames();
while (tableNames.hasMoreElements()) {
String tableName = (String) tableNames.nextElement();
AttributeTable attTable = das.getAttributeTableN(tableName);
if (tableName.equals("NC_GLOBAL") || tableName.equals(... | 8 |
public void body()
{
// wait for a little while for about 3 seconds.
// This to give a time for GridResource entities to register their
// services to GIS (GridInformationService) entity.
super.gridSimHold(3.0);
LinkedList resList = super.getGridResourceList();
// in... | 6 |
public String cleanText () {
// Time-saving check.
if (source.indexOf ("<lj") < 0) {
return source;
}
sourceLength = source.length ();
// Create a mirror string which is all lower case, to facilitate tag matching
lcSource = source.toLowerCase... | 8 |
public String searchPostDiscussion(String url){
String discussionUrl = "";
if(url.contains(PaginationParameters.getPostsUrlPattern())){
String urlWithoutPattern = url.substring(0, url.indexOf(PaginationParameters.getPostsUrlPattern()));
try {
@SuppressWarnings("resource")
final Scanner scanner = new ... | 4 |
@PUT
@Path("/v2.0/subnets/{subnetId}")
@Produces(MediaType.APPLICATION_JSON)
public Response updateSubnet(@PathParam("subnetId") String subnetId, final String request) throws MalformedURLException, IOException{
//Convert input object NetworkData into a String like a Json text
Object sub;
sub = JsonUtility.from... | 1 |
public IMessage decrypter(IMessage crypte, String key) {
/*
* Cette mthode lit d'abord la cl l'aide de remplirArray, puis
* dcode les caractres un un via des appels repetes encoderChar
*/
long d=new Date().getTime();
this.remplirArray(key);
char[] c=new char[crypte.taille()];
int v=-1;
int y=-1;... | 5 |
public void setWindowOpaque(Window window, boolean isOpaque) {
try {
// prevent setting if not supported
if(!isTranslucencyCapable(window.getGraphicsConfiguration()) ||
!isTranslucencySupported(Translucency.PERPIXEL_TRANSLUCENT, window.getGraphicsConfiguration().getDevice())) {
return;
}
setWindo... | 3 |
@Override
void removeChild(@SuppressWarnings("unused") Node child)
{
// Remove child
if(this._caso_ == child)
{
this._caso_ = null;
return;
}
if(this._valor_ == child)
{
this._valor_ = null;
return;
}
... | 3 |
public boolean beq(String instruction) {
String[] instArray = instruction.split(" ");
Register source1 = getRegister(1, instArray);
Register source2 = getRegister(2, instArray);
int imm = Integer.parseInt(instArray[3]);
if (source1.getValue().equals(source2.getValue())) {
int pcValue = binaryToDecimal(regi... | 1 |
public boolean WC() {
if(WCTimer <= 0) {
if(TreeHP == 0) {
AddGlobalObj(TreeX, TreeY, 1341, 0, 10);
sendMessage("This tree has run out of logs");
ResetWC();
return false;
}
else {
if(!hasAxe()) {
sendMessage("You need an axe to chop down this tree.");
ResetWC();
}
else if(hasAxe()) {
addSkillXP(WCxp, 8);
if(!addItem(l... | 5 |
public synchronized Class<?> compileSource(String name, String code) throws Exception {
Class<?> c = cache.get(name);
if (c == null) {
c = compileSource0(name, code);
cache.put(name, c);
}
return c;
} | 3 |
private boolean jj_3R_36()
{
Token xsp;
xsp = jj_scanpos;
if (jj_scan_token(21)) {
jj_scanpos = xsp;
if (jj_scan_token(22)) {
jj_scanpos = xsp;
if (jj_scan_token(23)) {
jj_scanpos = xsp;
if (jj_scan_token(24)) {
jj_scanpos = xsp;
if (jj_scan_token(38)) {
jj_scanpos = xsp... | 6 |
public void setWeightsAsResponses(){
this.weightsEntered = false;
this.weightOption = 1;
if(this.nResponses>0){
this.weights = new double[this.nResponses];
for(int i=0; i<this.nResponses; i++){
this.weights[i] = Math.abs(this.responses[i]);
... | 2 |
private static double getSigma(int threshold, double[] probabilities) {
double w1 = 0;
double w2 = 0;
for (int i = 0; i < probabilities.length; i++) {
if (i <= threshold) {
w1 += probabilities[i];
} else {
w2 += probabilities[i];
}
}
if (w1 == 0 || w2 == 0) {
return 0;
}
double mu1 = 0... | 6 |
public boolean areWeSame(MyLogger myLogger){
boolean bothAreSame = false;
if(this == myLogger)
bothAreSame = true;
return bothAreSame;
} | 1 |
private void remCallObj(Long key) {
sync.remove(key);
} | 0 |
public boolean HasPermission(Player player, String perm) {
if (player instanceof Player) {
// Real player
if (player.hasPermission(perm)) {
return true;
}
} else {
// Console has permissions for everything
return true;
}
return false;
} | 2 |
final int[][] method1036(int i, int j) {
if (i > -94) {
anInt1812 = -1;
}
if (~anInt1808 == ~anInt1810) {
aBoolean1822 = aClass142_Sub29Array1809[j] == null;
aClass142_Sub29Array1809[j] = StrongReferenceHolder.aClass142_Sub29_5003;
return ... | 5 |
@SuppressWarnings("static-access")
public void scanForIPs() {
Thread t = new Thread() {
public void run() {
status.setText("Scanning network for reachable servers");
repaint();
String IPV4 = "";
try {
String currentIP = getLocalAddress().toString().replaceFirst("/", "");
String[] parts =... | 8 |
public ByteVector putByteArray(final byte[] b, final int off, final int len) {
if (length + len > data.length) {
enlarge(len);
}
if (b != null) {
System.arraycopy(b, off, data, length, len);
}
length += len;
return this;
} | 2 |
public static final AttackInfo parseDmgM(final LittleEndianAccessor lea) {
final AttackInfo ret = new AttackInfo();
lea.skip(1);
ret.tbyte = lea.readByte();
ret.targets = (byte) ((ret.tbyte >>> 4) & 0xF);
ret.hits = (byte) (ret.tbyte & 0xF);
ret.skill = lea.readInt();
switch (ret.skill) {
case 5101004: //... | 7 |
public boolean canBearOff(Color player){
int count = 0;
if (player == this.getPlayer2()){
for (int i = 1; i < 7; i++){
if (this.getPoint(i).size() > 0) {
count += (BackgammonModel.getColor(this.getPoint(i)) == player) ? this.getPoint(i).size() : 0;
}
}
count += this.getPlayer2Home().size();
... | 8 |
private int minMove(Board prev, int depth, int alpha, int beta)
{
moves++;
if(depth >= maxDepth) return prev.getScore(); // exceeded maximum depth
int minScore = MAX_SCORE;
Board b = new Board(prev);
b.turn(); // min player's turn
for(int j = 0; j < size; j++)
{
for(int i = 0; i < siz... | 9 |
public int inLocalDB(String file_path) {
int index = -1;
DBLikeFileObject element = null;
Iterator<DBLikeFileObject> itr = localDB.iterator();
for (int i = 0; i < localDB.size(); i++) {
element = itr.next();
if (element.getLocalFilePath().equals(file_path)) {
index = i;
}
}
return index;
} | 2 |
private boolean processCommand(Command command)
{
boolean wantToQuit = false;
if(command.isUnknown()) {
System.out.println("I don't know what you mean...");
return false;
}
String commandWord = command.getCommandWord();
if(commandWord.equals... | 6 |
public static String escapeHtmlString(String src) {
if (src == null) {
return src;
}
StringBuffer sb = new StringBuffer();
for (int i = 0; i < src.length(); i++) {
char ch = src.charAt(i);
switch (ch) {
case '&':
if (i + 1 <= src.length() && src.charAt(i + 1) == '#') {
sb.append('&');
}... | 9 |
public static int findNumDays(String fileName)
{
int lineNumber = 0;
String line;
try {
BufferedReader br = new BufferedReader( new FileReader(fileName));
while( (line = br.readLine()) != null)
{
lineNumber++; ... | 3 |
public String GetItemName(int ItemID) {
for (int i = 0; i < server.itemHandler.MaxListedItems; i++) {
if (server.itemHandler.ItemList[i] != null) {
if (server.itemHandler.ItemList[i].itemId == ItemID) {
return server.itemHandler.ItemList[i].itemName;
}
if (ItemID == -1)... | 4 |
private List<Position> getEnclosedPositions(Position from, Position to, Direction dir) {
List<Position> enclosedPositions = new ArrayList<Position>();
Position newPos = from;
while (!newPos.equals(to)) {
enclosedPositions.add(newPos);
newPos = dir.newPosition(newPos);
if (!getGrid().validPosition(newPos)... | 2 |
public void removeEdges(QueryVertex v1, QueryVertex v2) {
List<QueryEdge> adj1 = this.edges.get(v1);
for(Iterator<QueryEdge> it = adj1.iterator(); it.hasNext(); ) {
QueryEdge e = it.next();
if(e.getEndPoint().equals(v2))
it.remove();
}
if(adj1.size() == 0) {
this.edges.remove(v1);
}
List<Que... | 6 |
public ProfileEditorDialog(LaunchFrame instance, final String editingName, boolean modal) {
super(instance, modal);
setupGui();
getRootPane().setDefaultButton(update);
username.setText(UserManager.getUsername(editingName));
name.setText(editingName);
if (UserManager.g... | 6 |
public void deposit(BigInteger amount) throws IllegalArgumentException {
if ( (amount == null) || (amount.compareTo(BigInteger.ZERO) <= 0) )
throw new IllegalArgumentException();
setBalance(this.getBalance().add(amount));
} | 2 |
public static int CMM2(int[] dimension, int[][] array, String[][] sequence, int start, int end){
if (start >= end) return 0;
int temp;
for(int i = start; i < end; i++){
if(array[start][i] == Integer.MAX_VALUE)
array[start][i] = CMM2(dimension, array, sequence, start, i);
if(array[i+1][end] == Integer.MA... | 5 |
private static void copyFile(File sourceFile, File destFile) throws IOException {
if (!destFile.exists()) {
destFile.createNewFile();
}
FileChannel source = null;
FileChannel destination = null;
try {
source = new FileInputStream(sourceFile).getChannel();... | 3 |
public DashboardPanel(MainFrame owner) {
User user = Service.getCurrentUser();
this.owner = owner;
this.repainter = Updater.getInstance();// new Updater(60000);
this.repainter.registerObserver(this);
this.setLayout(new BorderLayout());
pnlDashboardCenter = new JPanel();
pnlDashboardCenter.setLayout(new... | 3 |
double evaluateInstanceLeaveOneOut(Instance instance, double [] instA)
throws Exception {
DecisionTableHashKey thekey;
double [] tempDist;
double [] normDist;
thekey = new DecisionTableHashKey(instA);
// if this one is not in the table
if ((tempDist = (double [])m_entries.get(thekey)) == nu... | 7 |
public double opt(Function f, double eps)
{
eps *= Math.abs(a-b); // make accuracy relative
double x0 = Math.min(a,b);
head = new Node(null, x0, f.eval(x0));
x0 = Math.max(a,b);
Node nn = new Node(null, x0, f.eval(x0));
head.setNext(nn);
double xMax, yMax;
... | 7 |
public static long bruteforce() throws IOException{
System.out.println("Brute Force initiated.");
DataBuff Buff = new DataBuff(Main.DataFile);
ArrayList<String> Querry = new ArrayList<String>();
String stringLine = null;
double angle = Math.PI/2;
int indextwt = 0;
int indexque = 0;
String twt = null;... | 6 |
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.