method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
4579e02d-3874-4fd0-a5fe-18e0d7aaa11a | 8 | public static List<String[]> readCSVTable(Readable source, int numOfCells)throws IOException{
final int CELLS = numOfCells;
Scanner in = new Scanner(source);
List<String[]> vals = new ArrayList<String[]>();
StringBuffer exp = new StringBuffer("^");
for(int i = 0; i < numOfCells; i++){
exp.append("(.*)");
... |
5fc2287f-d92c-4340-8bbb-fb4bd4eff32c | 5 | public void start(String[] args) {
try {
if(args.length == 0) {
processDirectoryTree(new File("."));
} else {
for(String arg : args) {
File fileArg = new File(arg);
if(fileArg.isDirectory()) {
... |
fa85d94c-5840-4750-97fa-39c3a4e0c9b3 | 2 | public Evaluator(UnificationStrategy unifier, RuleResolver ruleResolver) {
if (unifier == null) {
throw new IllegalArgumentException(
"The given unifier must not be null.");
}
if (ruleResolver == null) {
throw new IllegalArgumentException(
... |
821173d2-1355-457b-b7c5-d2fd59ff2b4c | 9 | public static void main(String[] args)
{
BigInteger totalSum = BigInteger.ZERO;
BigInteger[][] arrangements = new BigInteger[51][50];
for (int i = 0; i <= 50; i++)
for (int j = 0; j < 50; j++)
arrangements[i][j] = BigInteger.ZERO;
arrangements[1][0] = BigInteger.ONE;
for (int i = 1; i < 50; i++)
{
... |
fcdd6a7e-5a97-427a-90eb-c2198519114a | 3 | public void addList (String name)
{
boolean jump = true;
for ( int i = usernames.size() - 1; i >= 0; i--)
{
if (usernames.get(i).equals(name))
{
jump = false;
}
}
if (jump)
{
usernames.add(name);
... |
33d5a004-cfb6-4671-a791-048158182e0a | 9 | public void resetAddObjectIndicator() {
addObjectIndicator = null;
switch (actionID) {
case ADDA_ID:
float sigma = (float) model.getElement(Element.ID_NT).getSigma();
addAtomIndicator.setFrame(-1, -1, sigma, sigma);
break;
case ADDB_ID:
sigma = (float) model.getElement(Element.ID_PL).getSigma();
... |
3e64dfdd-c8bb-4f83-9380-89b1868afc33 | 9 | private boolean find(int[] A, int start, int end, int target) {
if (start > end) return false;
int middle = start + (end - start) / 2;
if (target == A[middle]) return true;
if (A[start] < A[middle] || A[start] == A[middle] && check(A, start, middle)) {
if ... |
72d8ee0f-f6db-4dec-a597-66f457e1d12c | 1 | public void accept(NodeVisitor visitor) {
visitor.visitClass(this);
for(MethodNode method : methods) {
method.accept(visitor);
}
} |
2f560fec-b1ff-45f9-8a92-02fde2c4efcd | 5 | @Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Image)) {
return false;
}
Image other = (Image) object;
if ((this.id == null && other.id != null) || (this.id !... |
41959f0e-fefa-4095-bbef-d50362de84de | 1 | public void checkAllRestrictions()
{
//Iterate through all of them
for(Restriction r: restrictions){
r.check();
}
} |
81a6961f-ddd8-41c3-b3ef-993b576a024e | 9 | private void functionParserHelper(Node root, FunctionFactory factory)
throws ParsingException
{
// go through all elements in the section
NodeList children = root.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node child = children.item(i);
... |
8353ea40-506c-48af-854e-7abd655e5354 | 3 | int []insertionSort1(int arr[]){
int key;
for(int i=1;i<arr.length;i++){
key=arr[i];
for(int j=0;j<i;j++){
if(key<arr[j]){
swap(arr,i,j);
}
}
}
return arr;
} |
172d5188-740a-468a-b1ed-c6592b15f4ce | 6 | public void updateUser(){
users.removeAll(users);
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e) {
System.out.println("Where is your MySQL JDBC Driver?");
e.printStackTrace();
}
PreparedStatement ps = null;
... |
5a692997-84f3-4f50-91b6-025c302ac3eb | 5 | public String indent(final String str) {
boolean wasNL = false;
int indent = 0;
final StringBuilder sb = new StringBuilder();
for(final char c : str.toCharArray()) {
final boolean isNL = NL.indexOf(c) >= 0;
if(c == out) {
indent -= width;
}
if(wasNL && !isNL) {
do... |
1567a797-1e1e-4d47-b482-4045d0dd3bf3 | 5 | @Override
public void run() {
while(!Thread.interrupted()) {
try {
while(count < 100) {
Item item = new Item(++count);
if(market.storage.offer(item)) {
System.out.println("Produced " + item);
... |
e36b14d0-1e9a-4a67-ad31-b4b42d2cf1b2 | 7 | private void parseContent(String str) {
for (int i = 0; i < str.length(); i++) {
if (str.charAt(i) != ' ') {
matrix[contentRow][contentColumn] = str.charAt(i);
if (str.charAt(i) != '*' && str.charAt(i) != '-') {
Column column = riddle.getColumns().get(contentColumn)... |
cede1e8c-b188-44ce-967d-62ed18596b51 | 2 | public static void StopTrimTask() {
if (trimTask != null && trimTask.valid())
trimTask.cancel();
} |
749d06ff-9581-45b2-a232-a1cd1f9eb2e3 | 2 | public void ImageDWT_Color(int _numCoefficient)
{
// for color R
double[][] _r = ImageSetDWT_Byte(_numCoefficient, 0, 0);
// for color G
double[][] _g = ImageSetDWT_Byte(_numCoefficient, this.height, 0);
// for color B
double[][] _b = ImageSetDWT_Byte(_numCoefficient,... |
fa20fd0b-f459-4875-8685-83d38bd8b746 | 6 | @Override
public String toString() {
StringBuilder bld = new StringBuilder(newStructure.size() + "->");
bld.append("LEAF");
if (parent != null && parent instanceof ArrNode) {
bld.append(parent.toString());
}
bld.append("<");
if (oper != null) {
bld.append(oper);
bld.append("_");
}
if (val.is... |
51918647-60f1-409b-9e9c-9a88d6c1da9e | 4 | private void setCurrentBallStartingPosition() {
firedBall.setPosChange(4, 4);
switch (setCannon) {
case 0: firedBall.setPos(118, 18); break;
case 1: firedBall.setPos(635, 18); break;
case 2: firedBall.setPos(635, 535); break;
case 3: firedBall.setPos(118, 535); break;
}
} |
fc4c6b28-9a00-45de-a85b-50d62b7730c9 | 5 | @Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Usuario)) {
return false;
}
Usuario other = (Usuario) object;
if ((this.idUsuario == null && other.idUsuario !=... |
fe4d1443-f522-4f9a-ac8f-1e9c9162f7be | 4 | private void checkBestSolution() {
if (!haveBest) {
haveBest = true;
Particle particle = particles[0];
best.copyParticle(particle);
}
//currently only PROJECT_ACTUAL_DURATION
int currentBest = best.getBestProjectDuration();
int bestIndex = -1;
for (int particleIndex = 0; particleIndex < particl... |
5f71ca4f-3b6a-43aa-8fce-b3407236cf66 | 9 | private int jjMoveStringLiteralDfa2_0(long old0, long active0)
{
if (((active0 &= old0)) == 0L)
return jjStartNfa_0(0, old0);
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_0(1, active0);
return 2;
}
switch(curChar)
{
case 78:
... |
baaf842c-44c2-46e0-a850-72f4b14b8a7e | 9 | private void handler(SocketChannel sockChannel){
// Get the raw body as a byte []
byte [] fbuf = f.toByteArray();
// Create a BufferedReader for easily reading it as string.
ByteArrayInputStream bin = new ByteArrayInputStream(fbuf);
BufferedReader in = new BufferedReader(new InputStreamReader(bin));
... |
bc6ac693-a9d0-42e3-8b02-85739407985b | 8 | public void sendCell(ATMCell cell, IATMCellConsumer parent){
if(this.trace){
System.out.println("Trace (ATM NIC): Received cell");
if(this.link==null)
System.out.println("Error (ATM NIC): You are trying to send a cell through a nic not connected to anything");
if(this.parent!=parent)
System.out.print... |
b4dba484-6d3e-4bf6-a323-4cb61c92d0ab | 1 | public ListNode reverse(ListNode head){
ListNode dummy = new ListNode(0);
ListNode p = head;
while(p != null){
ListNode tmp = p;
p = p.next;
tmp.next = dummy.next;
dummy.next = tmp;
}
return dummy.next;
} |
ac5979d0-6cac-4dc7-8d72-8bc112323aaa | 4 | private void updateDirection() {
if (currentAction != ATTACK_SLASH && currentAction != ATTACK_FIRE) {
if (right) facingRight = true;
if (left) facingRight = false;
}
} |
ed605712-78e9-4262-95c6-9205aaf2b572 | 8 | public void render ( ) {
Arrays.fill(pixels, 0);
Arrays.fill(tilepixelref, null);
final int extray = 50;
final int ibx = (int) basex, iby = (int) basey;
yloop:
for ( int y = tiles.length - 1 ; y >= 0 ; y-- ) {
if ( basey + Config.TILE_SIZE[1] * (y + tiles[y].length) / 2 < -Config.TILE_SIZE[1] - ext... |
a0e4913f-db1d-4867-a0d4-90fcedf676f7 | 4 | public static void calculateNetwork(){
double sum = 0;
//first do the inputs to hidden
for(int hidNode = 0; hidNode < numHiddenNodes; hidNode++){
sum = 0;
for(int inNode = 0; inNode < inHid.length; inNode++){
sum += (input[inNode] * inHid[inNode][hidNode]);
}
sum += bias;
hiddenOutput[hidNode] ... |
82e460cf-248a-4585-a43f-a13ab9b0f1af | 7 | public static boolean isEmail(String input) {
int atIndex = input.indexOf("@");
if (atIndex == -1) {
return false;
}
String namePart = input.substring(0, atIndex);
if (!IndexOfFtw.validNamePart(namePart) || namePart.length() == 0) {
return false;
... |
f78873f9-a163-4229-a95b-4c94ccfef110 | 9 | private void testJceAvailability(int keyBitLength)
throws
EncryptionUnsupportedByPlatformException, PDFParseException {
// we need to supply a little buffer for AES, which will look
// for an initialisation vector of 16 bytes
final byte[] junkBuffer = new byte[16];
... |
14e9f5b7-8deb-4255-b1e6-d574dce628cd | 2 | public void timed() {
boolean captured = false;
try {
captured = lock.tryLock(5, TimeUnit.SECONDS);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
try {
System.out.println("tryLock(5, TimeUnit.SECONDS): " + captured);
... |
34d6d868-0cf6-41e2-957a-1bf64cd05b13 | 9 | private String parseFunction() {
double result;
String peek = ts.peek(0).value;
ts.get(); // clear function token
ts.get(); // clear (
result = Double.parseDouble(parseExpr());
ts.get(); // clear )
if(peek == "sin") {
return String.valueOf(Math.sin(result));
}
if(peek == "cos... |
f56d1967-1d63-46d8-aee4-cf13cd37ff83 | 9 | private boolean r_mark_suffix_with_optional_n_consonant() {
int v_1;
int v_2;
int v_3;
int v_4;
int v_5;
int v_6;
int v_7;
// (, line 132
// or, line 134
lab0: do {
v_1 = limit - cursor;
lab1: do {
// (, line 133
// (, line 133
// test, line 133
v_2 = limit - cursor;
// lit... |
d8919ee6-9332-4e3d-a25f-b5d5dcf39591 | 0 | public Ligne choixCombi(){
Random rand = new Random();
int indiceAleatoire = rand.nextInt(listeCombi.size());
return listeCombi.get(indiceAleatoire); // On prend une combinaison aléatoire dans la liste
} |
20c5213c-d063-4d3c-bddf-4fdec1e7e560 | 4 | public void search(String term){
view.getDetailsPanel().setVisible(false);
Database db = Database.getInstance();
if(term.equals("")){
JOptionPane.showMessageDialog(view, "Please Specify a search term");
}
else{
term = StringUtilities.searchCheck(term);
if(searchterms.contains(term.toString())){
... |
c39392cb-5fed-4bd6-8977-81e318b0d4be | 6 | @Override
public void render(float delta) {
//TICK
fps.log();
cameraScroller.update();
world.step(1f/60f, 6, 2);
Array<Body> bodies = new Array<Body>(); world.getBodies(bodies);
obstacles.clear();
for(Body body : bodies){
if(body.getUserData() instanceof BodyData){
BodyData data = (BodyData) body.... |
b2daa87e-0a3e-4e72-87d7-b9d415405f9e | 8 | public static void run(String[] args) throws IOException, InterruptedException
{
Runtime rt = Runtime.getRuntime();
Process ps;
boolean vMode = false;
String ip = GetIP.run();
String[] newNode = {"["+ip+"]"," address "+ip," use_node_name yes"};
if(args[0].equalsIgnoreCase("-v"))
{
... |
bb1192bf-42e3-44ca-9a4d-020c48d8cfba | 4 | public String getItemType(int slot)
{
if(slot == 0)
return "Sword";
else if(slot == 1)
return "Bow";
else if(slot == 2)
return "Lantern";
else if(slot == 3)
return "Potion";
return "";
} |
3287b499-501f-4610-90db-936f7efc5c0e | 9 | public String activate(Participant p, LifeEventType lifeEventType, HtmlColor backcolor) {
if (lastDelay != null) {
return "You cannot Activate/Deactivate just after a ...";
}
if (lifeEventType == LifeEventType.CREATE) {
pendingCreate = new LifeEvent(p, lifeEventType, backcolor);
return null;
}
if (la... |
fe478fe8-75ca-4e4d-b0a9-c9356d082c3d | 2 | public static byte aa2Code(char aa) {
if (aa == '-') return -1;
byte c = AA_TO_CODE[(byte) aa];
if (c < 0) throw new RuntimeException("Unknown code for amino acid '" + aa + "' (ord: " + ((int) aa) + " )");
return c;
} |
5ef204ea-6fd9-41ef-8f40-6698f14c3330 | 8 | protected boolean computeCell(int col, int row)
{
boolean liveCell = getCell(col, row);
int neighbours = countNeighbours(col, row);
boolean nextCell = false;
if (neighbours < 2) nextCell = false;
if (liveCell && (neighbours == 2 || neighbours == 3)) nextCell = true;
if (liveCell && neighbours... |
1972cce4-0ef1-4d46-84ab-4e5039ac1fcb | 8 | public static boolean open(JTextComponent textComponent)
throws TextComponentUtilException {
InputStream is = null;
BufferedReader reader = null;
try {
NamedInputStream selectedInputStream = FileChooserFactory
.getFileChooser().open();
if (... |
f156b5ea-dda5-439f-9247-8a7fa87277c3 | 1 | public void haeTunnisteet(){
kasittelija.luoLukija();
String rivi = kasittelija.lueTiedostoRiviKerrallaan();
while (!rivi.equals("TIEDOSTON LOPPU")){
String[] rivinSanat = rivi.split("\t");
tunnisteet.add(rivinSanat[3]);
rivi = kasittelija.lueTiedostoRiviKerra... |
82407947-c923-46cc-8569-08a0e4691669 | 5 | public static void printMaxScore(String anInputPath, String anOutputPath) throws KadaiException {
// 出力ファイルパスをチェック
if (null == anOutputPath || "".equals(anOutputPath)) {
throw new KadaiException(ErrorCode.FILE_IO);
}
// ファイル読み込み & ファイル文字列をカンマでスプリット
String[] aFileDataArray = KadaiUtill.createDataList(anIn... |
513f8c95-7a96-42b6-85d4-9e6bc315898c | 5 | private void smokePlayer(Player player) {
if (plugin.getPluginConfig().effects)
{
Location loc = player.getLocation();
World w = loc.getWorld();
int repeat = 0;
while (repeat < 1)
{
for (double x = (loc.getX() - 3); x <= (loc.getX() + 3); x++)
{
for (double y = (loc.getY() - 3); y <= (lo... |
f8a97918-7611-40d1-8819-303d86125f13 | 2 | public static void generateResults(ConcurrentHashMap allDocPairs, int minMatchingTokens) {
resultsDocPairs.clear();
Iterator it = allDocPairs.entrySet().iterator();
while (it.hasNext()) {
Map.Entry termEntry = (Map.Entry) it.next();
int matchingTokens = Integer.parseInt... |
04ae6c4c-1619-4b3d-bec1-e94c200c7eb0 | 0 | protected Icon getIcon() {
java.net.URL url = getClass().getResource("/ICON/delete.gif");
return new javax.swing.ImageIcon(url);
} |
e0b5a532-0ff2-4e2b-a6cb-efcc20d59999 | 2 | public ChannelHandler(CatChat plugin) {
this.plugin = plugin;
file = new File(plugin.getDataFolder(), "channel.data");
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
}
}
} |
69590eb4-b3a2-415c-8cd2-a3a5d764de08 | 3 | public void cluster()
{
// 数据归一化
normalize();
// 标记是否需要重新找初始点
boolean needUpdataInitials = true;
// 找初始点的迭代次数
int times = 1;
// 找初始点
while (needUpdataInitials) {
needUpdataInitials = false;
result.clear();
System.out.println("Find Initials Iteration" + (times++) + "time(s)");
// 一次找初始点的尝试和... |
b8f39eb3-7cdb-4cf8-915e-09031b244496 | 9 | @Override
public int compareTo(Object o) {
Point2D point2D = (Point2D) o;
if (compareModel == CompareModel.X) {
if (x > point2D.x) {
return 1;
} else if (x < point2D.x) {
return -1;
}
} else if (compareModel == CompareModel.... |
ccb1d833-e32e-4138-b58f-35027852684a | 9 | public void metodoSorteo(int pos)
{
double random;
for(int i = pos; i < k; i++)
{
//se generan k numero aleatorios
random = Math.random();
for (int j = 0; j < pb.poblacion_crom; j++)
{
... |
af3271c7-cc9e-49dc-8871-21bb0e0f481a | 2 | public AnnotationVisitor visitAnnotation(final String name,
final String desc) {
buf.setLength(0);
appendComa(valueNumber++);
if (name != null) {
buf.append(name).append('=');
}
buf.append('@');
appendDescriptor(FIELD_DESCRIPTOR, desc);
buf.append('(');
text.add(buf.toString());
TraceAnnotationV... |
b3774fed-6be7-45df-b9c2-24b222aa1397 | 7 | private Sprite scaffoldFor(int size, int high, float condition) {
if (size == 1) return SCAFF_MODELS[0].makeSprite() ;
if (condition < 0) condition = 0 ;
if (condition > 1) condition = 1 ;
final int stage = scaffoldStage(size, high, condition) ;
//
// Otherwise, put together a composite sprite ... |
48aba3b1-07ae-4b60-9646-62cfae80d6d9 | 2 | public LocalField(int modifiers, Class type, java.lang.String name, Object constValue){
if (Debug.enabled)
Debug.check((constValue==null) || ((modifiers & 0x0018) ==0x0018));
this.type=type;
this.name=name;
this.modifiers=modifiers;
this.constValue=constValue;
}; |
08bcfed5-2330-463f-ba27-2ca3f13ba5cf | 9 | public boolean skipPast(String to) throws JSONException {
boolean b;
char c;
int i;
int j;
int offset = 0;
int length = to.length();
char[] circle = new char[length];
/*
* First fill the circle buffer with as many characters as are in the
... |
bd798306-3943-4cb1-b721-78bf915cf012 | 7 | @SuppressWarnings("unchecked")
public final static short elementNumberFromSymbol(String elementSymbol) {
if (htElementMap == null) {
Hashtable map = new Hashtable();
for (int elementNumber = elementNumberMax; --elementNumber >= 0;) {
String symbol = elementSymbols[elementNumber];
Integer boxed = new In... |
f43e4eba-dc89-4dce-919e-b89f152b2d2c | 8 | public final String toString()
{
char myChar =baseValue;
if(this instanceof Pawn)
{
myChar+=pawnValue;
}else if(this instanceof Queen)
{
myChar+=queenValue;
}else if(this instanceof Bishop)
{
myChar+=bishopValue;
}else if(this instanceof Knight)
{
myChar+=knightValue;
}else if(this inst... |
076ea830-3912-4d67-86b9-b7d42c09bb0a | 1 | public int getNextKey() {
if (count-- == 0) {
isaac();
count = 255;
}
return results[count];
} |
1bc3e99b-f5ae-4859-ace2-b68fbead05e1 | 1 | public static int intValue(byte b) {
if ( b < 0 )
return b + 256;
else
return b;
} |
73003ba5-9502-44ad-b481-131cfb91d450 | 7 | public Node addNew(String s, int c, int p) {
char first = s.charAt(0);
if (s.length() > 1) {
for (Node child : children) {
if (child.data == first) {
return child.addNew(s.substring(1), c, this.code);
}
}
} else if (s.le... |
be85ca2c-05f2-434e-85fc-6da89626ec11 | 1 | private boolean doMore() {
return (wordsToRun == -1) || (wordsSolved < wordsToRun);
} |
86e5d874-415f-4b53-bbed-8ab81dc8c489 | 9 | @Override
public GameState use(Game game) {
List <Item> tempweap = null;
List <Npc> npcs;
npcs = game.getCurrentRoom().getNpcs();
Killable killablenpc = null;
for(Npc creature : npcs){
if(creature instanceof Killable){
killablenpc = (Killa... |
9d47d755-1f35-4767-9ea0-8b0dab94d17e | 3 | private void fireInferenceStatusChanged(final InferenceStatus oldStatus) throws RuntimeException {
Object[] curListeners = getInferenceListeners();
List<Exception> errors = new ArrayList<Exception>();
for (int i = curListeners.length - 1; i >= 0; i -= 1) {
try {
((InferenceWorkerListener) curL... |
cdbda5b2-f37d-484e-8361-e16bbfbccafe | 5 | public ToolBarExamples() {
this.toolBar = new ToolBar(this.shell, SWT.NONE);
ToolItem itemPush = new ToolItem(this.toolBar, SWT.PUSH);
itemPush.setText("PUSH item");
ToolItem itemCheck = new ToolItem(this.toolBar, SWT.CHECK);
itemCheck.setText("CHECK item");
ToolItem itemRadio1 = new ToolItem(this.toolBa... |
1ed9a7a5-d206-4acb-86e8-ed6f3a296293 | 8 | static AccessibleObject[] computePropertyDependencies(Object obj, Map<String,String> properties) {
// List of Fields and Methods of the protocol annotated with @Property
List<AccessibleObject> unorderedFieldsAndMethods = new LinkedList<>() ;
List<AccessibleObject> orderedFieldsAndMethods = new Link... |
a0f52b7a-9251-4e10-84d5-d37e189737d5 | 4 | public boolean maintainBounderies(float pf_width, float pf_height) {
/*Check if the shot is outside the canvas bounderies*/
if(x - radius < 0) {
return true;
}
else if((x + radius) > pf_width) {
return true;
}
if(y - radius < Breakout.STATUS_FIELD_HEIGHT) {
return true;
}
else if(y + radius ... |
a78e0941-5aab-40eb-9137-74c96ef2ee18 | 8 | public void move(){
if( this.direction == Bullet.direction_up){
this.location_y -= this.speed ;
}else if(this.direction == Bullet.direction_down){
this.location_y += this.speed ;
}else if(this.direction == Bullet.direction_left){
this.location_x -= this.speed ;
}else if(this.direction == Bullet.directi... |
2908ec4c-777f-4809-85b8-893ebbb3534d | 0 | public static int m_bf2(final int n, final int c) {
return (int) Math.pow(2, Math.ceil(log(c*n,2)));
} |
c9358a57-f75f-4999-aef0-505bb2d941a4 | 5 | private void updateTabla(){
//** pido los datos a la tabla
Object[][] vcta = this.getDatos();
//** se colocan los datos en la tabla
DefaultTableModel datos = new DefaultTableModel();
tabla.setModel(datos); ... |
93da4e67-d349-424d-a4ea-c2bce9f4858d | 4 | public Card (String rank, String suit){
this.rank = rank;
this.suit = suit;
switch (rank){
case "Jack":
this.value = 11;
break;
case "Queen":
this.value = 12;
break;
case "King":
... |
065f388a-29d2-4f4f-9245-d52d74dcb99a | 0 | @Test
public void testBruteForce() {
String docs = "substring search application";
String pattern = "app";
String pattern2 = "apa";
int idx1 = StringSearch.bruteForceBackup(pattern, docs);
assert(idx1 == docs.indexOf(pattern));
int idx2 = StringSearch.bruteForceBackup(pattern2, docs);
assert(idx2 ==... |
d83ff42b-3928-410f-b5b1-19c6af3704c6 | 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... |
18ebd631-0ad0-4a7d-ad94-eb4b1a7d5797 | 1 | private boolean startServerSocket() {
try {
serverSocket = new ServerSocket(port);
listener.connectionSuccessful();
serverSocket.setSoTimeout(SOCKET_TIMEOUT);
return true;
} catch (IOException e) {
listener.onConnectionFailed(null, port, e);
... |
09aedc91-5d49-4b51-aad2-e246d6a3ceaf | 6 | public EnumAxis getFlip()
{
switch (this)
{
case X_UP:
return X_DOWN;
case Y_UP:
return Y_DOWN;
case Z_UP:
return Z_DOWN;
case X_DOWN:
return X_UP;
case Y_DOWN:
return Y_UP;
case Z_DOWN:
return Z_UP;
}
return null;
} |
e5a6d1d1-7477-45b3-9fbf-077e10321cc3 | 4 | @Override
public void tick(LinkedList<GameObject> object) {
if (HP <= 0) {
HP = 0;
isInvulnerable = true;
isAlive = false;
Game.setState(Game.STATE.GAMEOVER);
}
x += velX;
y += velY;
if (falling || jumping) {
velY ... |
2792f1ec-bd92-4c59-b6e3-d536e696bf11 | 9 | public String findAndExtractSong(String url,String inputLyricsSnippet){
//Problem: Try to find optimal length of lyricsSnippet, because sometime there is problem to find where Lyrics starts.
int startIndex = -1;
int n = 31;
String lyricsLine = "";
do{
n = n-1;
while(n+5>=inputLyricsSnippet.lengt... |
53f34478-273a-437b-93e6-2850c3b9b43d | 7 | @SuppressWarnings("deprecation")
private void addSlideShowCharData(String chars) {
// element the chardata belongs to must have its name on top of the
// stack
// decide which object the data belongs to and add it
if (parseStack.isEmpty() != true) {
if (parseStack.peek().equals("text"))
text.setData(cha... |
acf0fc77-1604-42ff-8a24-6a0e8ae61d45 | 7 | private void setNormalFieldOnPreparedStatement(PreparedStatement statement, Entry<Integer, Object[]> paramEntry) {
int index = paramEntry.getKey();
Object[] valueSet = paramEntry.getValue();
Field valueField = (Field) valueSet[0];
Object valueFieldInstance = valueSet[1];
Class<?> valueClass = valueField.getTy... |
2554b39e-7c49-455a-b269-8e4e12595280 | 8 | public static void openURL(String url) {
String osName = System.getProperty("os.name");
try {
if (osName.startsWith("Mac OS")) {
Class<?> fileMgr = Class.forName("com.apple.eio.FileManager");
Method openURL = fileMgr.getDeclaredMethod("openURL", new Class[] { String.class });
openURL.invoke(null, new... |
4c7c00a1-d80f-411c-949d-f32e542edd49 | 6 | public static void makeGrid(Container parent, int rows, int cols, int initialX, int initialY, int xPad, int yPad) {
SpringLayout layout;
try {
layout = (SpringLayout) parent.getLayout();
} catch (ClassCastException exc) {
System.err.println("The first argument to makeGrid must use SpringLayout.");
return... |
f3bb1114-5bbe-4ee5-98ff-95644c16eb38 | 2 | public Body getBodyByName(String name){
for(Body u : allBodys){
if(u.getName() == name){
return u;
}
}
return null;
} |
d43b87d1-ac22-4f9d-9d85-d5ab30607d0a | 4 | final public CycList univForm(boolean requireEOF) throws ParseException, java.io.IOException, UnsupportedVocabularyException {
CycObject var = null;
CycObject sent = null;
CycList val = new CycList();
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case FORALL_CONSTANT:
jj_consume_token(FORALL_CONSTANT);
... |
e72bef6e-85a8-4da2-99ad-234cb4a34127 | 8 | public Updater(Plugin plugin, int id, File file, UpdateType type, boolean announce) {
this.plugin = plugin;
this.type = type;
this.announce = announce;
this.file = file;
this.id = id;
this.updateFolder = plugin.getServer().getUpdateFolder();
final File pluginFile... |
0f276588-32dd-4e3a-b003-f50756ae63c3 | 1 | public void visit_getfield(final Instruction inst) {
final Type type = ((MemberRef) inst.operand()).nameAndType().type();
stackHeight -= 1;
if (stackHeight < minStackHeight) {
minStackHeight = stackHeight;
}
stackHeight += type.stackHeight();
} |
44edd854-c4f7-4340-9562-8789c72fb405 | 4 | private void colorLowTemp(int i, int j, long temp) {
if (temp == MIN_TEMP) {
drawing.setRGB(i, j, minPoint);
return;
}
if (temp == LOW_TEMP) {
drawing.setRGB(i, j, lowPoint);
return;
}
for (int k = 0; k < tempRangesLow.length; k++) ... |
8e7b3db3-1b4f-4a4b-96f5-80f22f8db551 | 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... |
69a0543e-dfaa-45f3-ac5b-2d15f879cc8a | 9 | public void switchMediaLibraryToUNCPaths()
{
if (mediaDir != null)
{
for (int i = 0; i < mediaDir.length; i++)
{
UNCFile file = new UNCFile(mediaDir[i]);
if (file.onNetworkDrive())
{
mediaDir[i] = file.getUNCPath();
}
}
}
if (mediaLibraryDirectoryList != null)
{
for (int i =... |
81376448-c93a-4985-951f-8758ef5a7cd9 | 7 | public static void activateClass(Stella_Class renamed_Class) {
{ Stella_Class activeobjectclass = Surrogate.typeToClass(Stella.SGT_STELLA_ACTIVE_OBJECT);
List supers = renamed_Class.classDirectSupers;
if ((activeobjectclass != null) &&
Stella_Class.subclassOfP(renamed_Class, activeobjectclass... |
ebe11bc4-1a9a-401b-a270-d9e5001ad00c | 8 | private boolean containsState(LockPieceState newState) {
if (newState.ADown) {
newState.ADown = false;
if (containsState(newState)) {
newState.ADown = true;
return true;
}
newState.ADown = true;
}
if (newState.BDown) {
newState.BDown = false;
if (containsS... |
38c58c16-8798-4a46-946b-80935bc29e4b | 8 | public static void decode( ByteChunk base64DataBC, CharChunk decodedDataCC)
{
int start = base64DataBC.getStart();
int end = base64DataBC.getEnd();
byte[] base64Data = base64DataBC.getBuffer();
decodedDataCC.recycle();
// handle the edge case, so we don't ha... |
b14d0dc6-41e3-4798-a9b4-4c1adec03a56 | 3 | public void tweak(Request request) {
if (request.getDrill() != null && request.getDrill().getEntries() != null && !request.getDrill().getEntries().getClass().equals(ArrayList.class)) {
request.getDrill().setEntries(new ArrayList<Entry>(request.getDrill().getEntries()));
}
} |
56d9ed0a-2beb-4848-8abf-200b2faed3b4 | 5 | public boolean mouseup(Coord c, int button) {
if ((folded) && (c.isect(Coord.z.add(cl.sz()), isz))) {
setfold(false);
return true;
}
if (dm) {
ui.grabmouse(null);
dm = false;
Config.setWindowOpt("chat_pos" + (folded ? "_folded" : ""), ... |
e0c60f57-e428-482b-ac64-66ccffbb0837 | 4 | public boolean testDeplacement(Point p) {
boolean estDeplacable = true;
if ((this.point.y == p.y || this.point.x != p.x) && (this.point.x == p.x || this.point.y != p.y)) {
estDeplacable = false;
}
return estDeplacable;
} |
29887338-feab-41e7-86d5-203351b0ffa8 | 2 | public void disabledInit() {
SmartDashboard.putBoolean("Enabled", false);
if(autonomouse != null) {
autonomouse.cancel();
}
if(teleop != null) {
teleop.cancel();
}
// Make sure the shooter doesn't start spinning again when the robot
// re-e... |
9e6adbdd-500c-46ee-bcbc-3eac7026fcc7 | 7 | static final public void term() throws ParseException {
unary();
label_2:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case MULTIPLY:
case DIVIDE:
;
break;
default:
jj_la1[3] = jj_gen;
break label_2;
}
switch ((jj_ntk==-1)?jj_ntk(... |
ed3cf118-0d69-45d0-9504-a6625f728c37 | 2 | @Override
public double arvo() throws IllegalStateException {
if (onTyhja()) {
throw new IllegalStateException();
}
if (this.eiSisallaLaskutoimituksia()) {
return seuraavaArvollinen.arvo();
}
return viimeinen.arvo();
} |
3c870cca-745c-4042-951d-28e2bb83ef18 | 9 | private boolean k(Player p) {
EntityPlayer minecraftPlayer = ((CraftPlayer)p).getHandle();
Random random = new Random();
double d3 = minecraftPlayer.locX;
double d4 = minecraftPlayer.locY;
double d5 = minecraftPlayer.locZ;
double d0 = d3 + (random.nextDouble() - 0.5D) * 3... |
2956ed0a-5291-4d45-9d9f-ff09346c18ec | 4 | public void load ()
{
synchronized (slotsMutex)
{
for (int i = 0; i < slots.length; i++)
{
String slot = properties.getProperty("slot" + i, "null");
if ( !slot.equals("null"))
{
try
... |
799f4b2f-eece-4ce6-bbd7-199282a64cb4 | 7 | public void paint(Graphics g){
g.drawImage(bg, 0, 0, this); //draw background
super.paint(g);
Graphics2D g2D = (Graphics2D)g.create();
if(pika1.getIfJump() == true){
if(pika1.getPowHit() == true)
g2D.drawImage(pika1.getImage4(), pika1.getX(), pika1.getY(), 100, 100, this);
else
g2D.drawIma... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.