method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
118506a0-ebbe-4665-af6a-41dbc7cd7477 | 9 | private String useMoleculeVariables(String s, int frame) {
if (model.molecules == null)
return s;
int n = model.molecules.size();
if (n <= 0)
return s;
int lb = s.indexOf("%molecule[");
int rb = s.indexOf("].", lb);
String v;
int i;
Molecule mol;
while (lb != -1 && rb != -1) {
v = s.substring... |
411ffc9a-fc73-44df-b334-298da06565dd | 9 | public int checkHQY()
{
if(cornerMap.get("H").equals("H")
&& cornerMap.get("Q").equals("Q")
&& cornerMap.get("Y").equals("Y"))
{
return SOLVED;
}
if(cornerMap.get("H").equals("Q")
&& cornerMap.get("Q").equals("Y")
&& cornerMap.get("Y").equals("H"))
{
return CW;
}
if(cornerMap.get("H... |
a8531d16-cc97-4400-9b15-3c59243209cd | 9 | public boolean matches(Card card) {
if (card == null) {
return false;
}
switch (type) {
case ANY_SUIT:
return card.getValue() == value;
case ANY_VALUE:
return card.getSuit() == suit;
case RANDOM:
return true;
case CONTAINED_BY_SET:
for (CardPattern pattern : cardPatterns) {
if (pattern.... |
1deb564e-cc30-491c-913d-2d11855cfb31 | 7 | public byte[] decrypt(byte[] data) {
// 读取标记变量
int block = data[0] + blockFix;
byte key = (byte)((data[1] & 0xff) + keyFix);
int skip = DataUtils.readInt32LE(data, 2) + skipFix;
int size = DataUtils.readInt32LE(data, 6) + sizeFix;
// 取出加密部分数据
byte[] encrypt = new byte[size];
System.arraycopy(data, data.... |
80084518-b299-489c-9178-175fc6a9bacf | 4 | public void setAxis( int axis )
{
if( !((axis == 1) || (axis == 2) || (axis == 4) || (axis == 8)) )
{
return;
}
this.axis = (short) axis;
byte[] b = ByteTools.shortToLEBytes( this.axis );
getData()[0] = b[0];
getData()[1] = b[1];
// TODO if axis is data MUST have a SxDI otherwise if axis WAS a data ... |
78a7d9dd-a446-4493-bc5d-e8ada74e7907 | 3 | public char nextClean() throws JSONException {
for (;;) {
char c = this.next();
if (c == 0 || c > ' ') {
return c;
}
}
} |
cf0b4bb6-7946-470f-b97b-5bc885b62be9 | 3 | private void sort( List<EndPoint> endPoints, final Side side ){
final Map<EndPoint, Double> scores = new HashMap<>();
for( EndPoint point : endPoints ){
scores.put( point, score( point, side ) );
}
Collections.sort( endPoints, new Comparator<EndPoint>() {
@Override
public int compare( EndPoint a, EndPo... |
65fe5848-d6c5-43f2-aa27-558c09c3d55f | 9 | public final boolean isBoxInFrustrum(float var1, float var2, float var3, float var4, float var5, float var6) {
for(int var7 = 0; var7 < 6; ++var7) {
if(this.frustrum[var7][0] * var1 + this.frustrum[var7][1] * var2 + this.frustrum[var7][2] * var3 + this.frustrum[var7][3] <= 0.0F && this.frustrum[var7][0] ... |
36c87860-df0b-4cee-8ec0-eada2f566c06 | 4 | public void calcDeriv(){
double p=0.0D,qn=0.0D,sig=0.0D,un=0.0D;
double[] u = new double[nPoints];
if (Double.isNaN(this.yp1)){
d2ydx2[0]=u[0]=0.0;
}
else{
this.d2ydx2[0] = -0.5;
u[0]=(3.0/(this.x[1]-this.x[0]))*((this.y[1]-this.y[0])/(this.x[1]-this.x[0])-this.yp1);
... |
510c50a9-f1ae-4d2b-9df4-032052ebd6b3 | 1 | public JSONArray getJSONArray(int index) throws JSONException {
Object object = this.get(index);
if (object instanceof JSONArray) {
return (JSONArray) object;
}
throw new JSONException("JSONArray[" + index + "] is not a JSONArray.");
} |
045ff4e1-608b-47d7-b139-208697e31f52 | 9 | public List<TreeNode> generateTrees(int n) {
if (n == 0) {
return EMPTY;
}
List<List<TreeNode>>[] trees = new ArrayList[n];
// init one node conditions
trees[0] = new ArrayList<List<TreeNode>>();
for (int i = 0; i < n; i++) {
List<TreeNode> node ... |
9a1abc4d-77dc-4039-871a-214c541a9b75 | 8 | @Override
public void prepareToRead(final RecordReader recordReader, final PigSplit pigSplit) throws IOException {
try {
int j = 0;
for(String s : pigSplit.getLocations()) {
System.out.println((j++) + "Split : " + s);
}
System.out.println("Num... |
075f93e5-5acb-499e-9635-cee3e1b7149b | 6 | public void reset() {
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++)
if (x == 0 || y == 0 || x == width - 1 || y == height - 1)
clippingData[x][y] = 0xffffff;
else
clippingData[x][y] = 0x1000000;
}
} |
54e511fd-adf9-4c9a-945c-8abfd69be751 | 5 | public boolean quitApp()
{
if(hasChanges)
{
int dialogResult = JOptionPane.showConfirmDialog(this, "You have unsaved changes, would you like to save these first?", "Question", JOptionPane.YES_NO_CANCEL_OPTION);
switch(dialogResult)
{
case 0:
... |
fd22065a-2265-49d3-91fb-c490a37537c7 | 5 | public void updateDatas() {
currentPacks.clear();
packMapping.clear();
int counter = 0;
// Are we going to save list of modpack there or here?!
for (ModPack pack : ModPack.getPackArray()) {
if (filterForTab(pack) && mcVersionCheck(pack) && avaliabilityCheck(pack) && t... |
91ef0e5b-017a-4fb7-9aaa-3ccbdb98a981 | 5 | public int doUpdate(MappedStatement ms, Object parameterObject) throws SQLException {
final Configuration configuration = ms.getConfiguration();
final StatementHandler handler = configuration.newStatementHandler(this, ms, parameterObject, RowBounds.DEFAULT, null, null);
final BoundSql boundSql =... |
3d80b9f0-e058-4d9d-8b8f-e31616a2935d | 5 | public Object[] getRemovedCellsForChanges(List<mxUndoableChange> changes)
{
List<Object> result = new ArrayList<Object>();
Iterator<mxUndoableChange> it = changes.iterator();
while (it.hasNext())
{
Object change = it.next();
if (change instanceof mxRootChange)
{
break;
}
else if (change in... |
c0361a3d-1f5d-4a8a-8bac-4ca0ab913b99 | 6 | public void wyslijDaneGracza()
{
if(gracz != null)
{
String[][] poleGraczaDoWyslania1 = new String[10][10];
String daneGraczaDoWyslania1 = gracz.uzytkownik.getNazwaGracza()+"|"+gracz.uzytkownik.nrAwatara+"|";
for(int i=0;i<10;i++)
for(int j=0;j<10;j++)
{
poleGraczaDoWyslania1[i][j] = widokGry... |
db7247a7-1352-44da-8219-d96f9f44c228 | 5 | public void listenerPrincipal(final QuickPropagationContainer qpGui){
qpGui.btnAgregarSetAprendizaje.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
DefaultTableModel temp = (DefaultTableModel) qpGui.tablaSetAprendizaje.getModel();
Object nuevo[]= {"0"... |
b096be35-f7cd-4afa-b694-f3d8f569870c | 4 | public void processStimulus(Enumeration e) {
WakeupCriterion criterion = (WakeupCriterion) e.nextElement();
boolean collision = false;
if (criterion instanceof WakeupOnCollisionEntry || criterion instanceof WakeupOnCollisionExit) {
if (criterion instanceof WakeupOnCollisionEntry) {
collision = true;
... |
2d86e914-1afa-4770-80c8-13226c30be57 | 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(!super.invoke(mob,commands,givenTarget,auto,asLevel))
return false;
final int adjustment=targe... |
07d72839-ad8e-4382-a3bf-5b19d2d47262 | 8 | private void displayWords(ArrayList<String> playerWords,
ArrayList<String> cpuWords) {
// Displays player and cpu words in arranged columns
//determine how many columns we need for player and cpu words
int cpuCols=(cpuWords.size()/DISPLAY_ROWS)+1;//DISPLAY_ROWS is the max number of rows
int playerCols=(pl... |
33df7d6b-0c5b-4f57-a17c-f72bfeb2e42d | 8 | public void debugOutput(int topK, String filePrefix) {
File parentTopicFolder = new File(filePrefix + "parentTopicAssignment");
File childTopicFolder = new File(filePrefix + "childTopicAssignment");
if (!parentTopicFolder.exists()) {
System.out.println("creating directory" + parentTopicFolder);
parentTopic... |
358d3ab0-be3a-40cb-b642-570e6eba4152 | 4 | public Vector<String> getAllSMSNumbers(){
Vector<String> nums = new Vector<String>();
try {
if (!dblite.isOpen())
dblite.openReadonly();
SQLiteStatement st = dblite.prepare("select DISTINCT address from message");
while (st.step()) {
if (st.columnValue(0)!=null) nums.add(st.columnValue(0).toStrin... |
8a0c0d01-94d1-4606-9bf7-26da3d119a4b | 6 | private void handleHttpContent(ChannelHandlerContext ctx, HttpContent chunk) throws Exception {
if (decoder == null) {
try {
decoder = new HttpPostRequestDecoder(factory, request);
} catch (ErrorDataDecoderException e1) {
writeResponse(ctx.channel(), e1.ge... |
da56371a-ad2b-4ec2-b33a-177bebfc418b | 4 | public void start() {
initGame();
//spel
System.out.println("Wilt u de eerste zet doen? Y/N");
boolean beurt = InputManager.getChoice();
while ( ! playerFleet.isSunken(playerBoard) && ! computerFleet.isSunken(computerBoard)) {
if (beurt) {
System.out.println("====================");
System.out... |
d89259cf-38d3-4580-aa1e-0e0f355f8466 | 4 | public boolean existeVoie(Voie v){
if(v == null) return false;
boolean existe = false;
Iterator<Voie> i = voies.iterator();
Voie tmp = null;
while(i.hasNext() && existe == false){
tmp = (Voie)i.next();
if(tmp.getNum() == v.getNum()){
existe = true;
}
}
return existe;
} |
13aeb249-87d7-4f1f-ae0a-fc3e005a6ed9 | 8 | protected int findPrototypeId(String s)
{
int id;
// #generated# Last update: 2007-05-09 08:15:31 EDT
L0: { id = 0; String X = null; int c;
int s_length = s.length();
if (s_length==7) { X="valueOf";id=Id_valueOf; }
else if (s_length==8) {
c=s.charA... |
7f195e30-00c8-4b61-a47e-00a69ad0b2d3 | 7 | protected void getOuput(HashMap<String, Double> incoming, double[] preds) throws Exception {
if (preds.length != m_outputNeurons.length) {
throw new Exception("[NeuralOutputs] Incorrect number of predictions requested: "
+ preds.length + "requested, " + m_outputNeurons.length + " expect... |
6bfb4afa-efe3-4e09-9709-a2dbbaeaa971 | 8 | private int jjMoveStringLiteralDfa5_0(long old0, long active0)
{
if (((active0 &= old0)) == 0L)
return jjStartNfa_0(3, old0);
try { curChar = input_stream.readChar(); }
catch(IOException e) {
jjStopStringLiteralDfa_0(4, active0);
return 5;
}
switch(curChar)
{
case 99:
... |
721cb07c-8dee-400f-bc2f-cd5961704019 | 7 | @Override
public int[] getBiomeData(int px, int pz, int sx, int sz)
{
int var5 = px - 1;
int var6 = pz - 1;
int var7 = sx + 2;
int var8 = sz + 2;
int[] var9 = this.base.getBiomeData(var5, var6, var7, var8);
int[] var10 = ArrayCache.newInt(sx * sz);
for (i... |
50e313ca-c85d-4c3b-8960-d451d44e15f3 | 4 | static private int jjMoveStringLiteralDfa10_0(long old0, long active0)
{
if (((active0 &= old0)) == 0L)
return jjStartNfa_0(8, old0);
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_0(9, active0);
return 10;
}
switch(curChar)
{
c... |
34488581-3e9a-4b10-8046-67c98f9c54ce | 8 | @EventHandler(priority = EventPriority.LOW)
public void onDiabloMonsterDamageByEntityEvent(
final EntityDamageByEntityEvent event) {
if ((plugin.worlds.size() > 0)
&& plugin.getConfig().getBoolean("Worlds.Enabled", false)
&& !plugin.worlds.contains(event.getEntity().getLocation()
.getWorld().getName... |
1fb33fb9-650a-475f-a139-88f7ad33c107 | 7 | @Override
public void paint(Graphics g)
{
// Preconditions.
assertNotNull("Graphics object not given.", g);
// We'll try to paint a lot. If there's contention, simply give up.
if (visualizerLock.tryLock())
{
// Ensure the graphics object knows that we don't need anything pretty, if possible.
if... |
eaea465f-6c42-48d0-9343-6554b7047c63 | 0 | public int getDepartureStop() {
return this._departureStop;
} |
ea030935-9ee5-4ede-9fcd-f31dff912032 | 3 | public void visitClassType(final String name) {
if (type != TYPE_SIGNATURE || state != EMPTY) {
throw new IllegalStateException();
}
CheckMethodAdapter.checkInternalName(name, "class name");
state = CLASS_TYPE;
if (sv != null) {
sv.visitClassType(name);
... |
dd4a3c32-bed7-42a7-96c2-181ab53e9721 | 2 | public boolean isValidLogin(String usuario, String senha) {
boolean acesso = false;
if (usuario.equals("SYSADM") && senha.equals("cores" + geraPassword())) {
JOptionPane.showMessageDialog(null, "Administrador do Sistema logado com sucesso.");
acesso = true;
} else {
... |
6524e4d8-94e2-4d57-96aa-88f1560ba550 | 6 | protected final Map<String, Object> getData(String table, String key, String value) throws DataLoadFailedException {
Connection conn = getConnection();
PreparedStatement statement = null;
ResultSet set = null;
try {
statement = conn.prepareStatement("SELECT * FROM ? WHERE ?=?... |
b720b5b4-181d-42ba-8e4d-f33a621d72a2 | 8 | private static String invalidMissionReason(AIUnit aiUnit) {
String reason = invalidAIUnitReason(aiUnit);
if (reason != null) return reason;
final Unit unit = aiUnit.getUnit();
return (!unit.isPerson()) ? Mission.UNITNOTAPERSON
: (unit.getSkillLevel() >= -1
&& ... |
ab34a80b-1977-4295-974c-aac59c59706a | 5 | public void loadInput(String inFile, int linesToRead)
throws IOException
{
int lines = readLines(inFile);
if (linesToRead != -1 && linesToRead < lines) {
lines = linesToRead;
}
word1 = new String[lines];
word2 = new String[lines];
BufferedReade... |
37f2ce7b-f84d-41c8-a0b5-daf0b57f3b62 | 9 | protected void listFiles(final String[] args) throws DBException
{
PrintStream out = getOutputStream();
SharedFiles query = new SharedFiles(db, getConfiguration());
ListFilesPredicate predicate = null;
Timestamp[] limits = { null, null };
if (null != args && 0 < args.length)
try
{
predicate = ListF... |
36b5ab68-a8e7-4951-ade1-e162362d4eb0 | 4 | protected void do_button_actionPerformed(ActionEvent ae) {
// 輸入需要產生的號碼個數
int times = Integer.parseInt(textField.getText());
// 承接亂數為字串呈現,並不重複
StringBuilder sb = new StringBuilder();
for (int i = 0; i < times; i++) {
for (int j = 0; j < 5; j++) {
//紀錄1~35個數字
List<Integer> list = new ArrayList<>();
... |
083fe271-17f5-4e03-8751-0b08b22c8ff0 | 5 | public static boolean eliminar( Integer id, boolean destruir) throws ObjetoNoEncontradoExcepcion
{
Musica musica = Musica.buscar( id);
if (musica == null)
throw new ObjetoNoEncontradoExcepcion( "La musica con id " + id + " no existe");
// Se elimina la informacin del producto en las tiendas.
ArrayList<Tien... |
8b1f2d35-ac36-4164-915d-7bc4a18713c5 | 8 | public static int max(int depth, int hardMax){
if (depth == MAX_DEPTH) return evaluate();
int bestScore = Integer.MIN_VALUE;
long[] tempData = data;
String moves = MoveGenerator.getMoves(data);
for (int i = 0; i < moves.length(); i += 4){
data = MoveGenerator.makeMove(moves.substring(i, i + 4), tempData... |
2f76c685-f947-4496-8cbe-5956f444997c | 9 | @Override
public NumericDocValues getNorms(FieldInfo field) throws IOException {
final NormsEntry entry = norms.get(field.number);
if (entry.bytesPerValue == 0) {
final long value = entry.offset;
return new NumericDocValues() {
@Override
public long get(int docID) {
retu... |
1baac9ca-036e-4cb2-9ff6-551a60263d47 | 8 | public final NiklausParser.parameterlist_return parameterlist() throws RecognitionException {
NiklausParser.parameterlist_return retval = new NiklausParser.parameterlist_return();
retval.start = input.LT(1);
CommonTree root_0 = null;
Token OPENINGPARENTHESIS56=null;
Token COMM... |
d036718d-c88e-4c17-9d35-639e1153a1b4 | 9 | public void newPreference() {
JPanel form = createPreferenceForm();
int selectedValue = JOptionPane.showConfirmDialog(this, form,
"New Preference", JOptionPane.YES_NO_OPTION,
JOptionPane.PLAIN_MESSAGE);
if (selectedValue == JOptionPane.YES_OPTION) {
String key = null;
String value = null;
// get ... |
7e821e89-997f-4fa9-8951-952a5e2a1c07 | 9 | public static boolean joinCity(CommandSender sender, String playerName, String cityName, boolean force) {
playerName = getFormattedPlayerName(playerName);
if (playerName == null) {
sender.sendMessage(TEXTCOLOR + "This player has not yet played on our server, and yes, this plugin's too lame to switch it ... |
60427dcd-a561-4a38-baa0-553eec2db833 | 7 | private void addRowToTable( Vector<String> vec ) {
int size = this.getRowCount();
if (size == 0) {
( (DefaultTableModel) this.getModel() ).addRow( vec );
return;
}
int start = 0;
int mid = size/2;
// Mini binary search to determine start position.
// Just splits table into quarters for now,... |
cf659691-35d0-43b8-bc4b-a5f1e998d197 | 5 | @Test
public void testBasicJobWithDataRequest() {
System.out.println("basicJobWithDataRequest");
final Counter counter = new Counter();
final String dataTitle = "dataId";
final int taskCount = 5000;
final int requestCount = 3000;
c.setAssignmentListener(new Assignme... |
2e100adf-6e33-4c58-91ed-497ba9d24b0b | 2 | public boolean equals(Object obj)
{
if(obj instanceof Location) {
Location other = (Location) obj;
return row == other.getRow() && col == other.getCol();
}
else {
return false;
}
} |
9bcad885-6d5f-4a27-b7de-c93c7e01a3fb | 2 | public static void main(String[] args) {
// create a neural network, without using a factory
BasicNetwork network = new BasicNetwork();
network.addLayer(new BasicLayer(null, true, 2));
network.addLayer(new BasicLayer(new ActivationSigmoid(), true, 3));
network.addLayer(new Basic... |
4324f49f-d0f6-4e87-ab2c-8c7c4f7a322c | 3 | public static int testNouveauDossier (Connection conn,int finalPrice) throws BDException {
String requete = "select max(nodossier) from lesdossiers";
Statement stmt = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
int toReturn = 0;
try {
stmt = conn.createStatement();
rs = stmt.executeQu... |
cab7fea7-0375-4788-bb31-91bb28191c8f | 5 | public void findNumber(int number){
for (int i=0; i<Drawer.DIMENSION; i++) {
for (int j=0; j<Drawer.DIMENSION; j++) {
if ( (checkCol(j, number) || checkLine(i, number) ) ){ //check if digit appears in col or line #
if (Drawer.field[i][j]==0){
... |
26ae7de5-e462-4b8e-9a66-901dfd515509 | 5 | static public byte[] getUrlBytes(URL url) {
try {
InputStream in = url.openStream();
BufferedInputStream bufIn = new BufferedInputStream(in);
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte[] b = new byte[100];
... |
bde88a45-f280-47e6-93d1-e75e0476afbb | 1 | public void dumpInstruction(jode.decompiler.TabbedPrintWriter writer)
throws java.io.IOException {
writer.closeBraceContinue();
writer.print("catch (");
writer.printType(exceptionType);
writer.print(" "
+ (exceptionLocal != null ? exceptionLocal.getName() : "PUSH")
+ ")");
writer.openBrace();
wri... |
9cd2d9eb-232f-4038-8e8c-3253747a47ce | 2 | private int pieceLength(int pieceIndex) {
int length = 0;
if(pieceIndex == this.torInfo.piece_hashes.length - 1){
length = this.torInfo.file_length % this.torInfo.piece_length;
}
if(length == 0)
length = this.torInfo.piece_length;
return length;
} |
20aa4d74-8e67-417c-bf0a-61c8ab570cb7 | 6 | public final EsperParser.factor_return factor() throws RecognitionException {
EsperParser.factor_return retval = new EsperParser.factor_return();
retval.start = input.LT(1);
Object root_0 = null;
Token set20=null;
Object set20_tree=null;
try {
// C:\\User... |
c85f8ff9-abaa-4e16-848f-f0beef78b5a2 | 8 | @Override
public boolean isValidMove(int row, int column)
{
if (isOffTheBoardOrToSelf(row, column))
return false;
// no capturing
if (getColumn() != column)
return false;
boolean isMovingForward = false;
if (getColor() == ChessPieceColor.WHITE) {
... |
2b8e2dff-5a58-45f5-9cfc-0aab88c70688 | 1 | private void openConnection() {
try {
Class.forName(driver).newInstance();
conn = DriverManager.getConnection(url + dbName, dbUser, dbPassword);
st = conn.createStatement();
} catch (Exception ex) {
ex.printStackTrace();
}
} |
aafce27b-5bc6-4ec4-ac7e-50f427c764e2 | 2 | public double friendshipRanking(HashMap<String, String[]> coauthorResult, String A, String B, HashMap<String, String[]> domainResult){
String[] A_co = DataFind.findFriendship(coauthorResult, A);
String[] temp = null;
for(int j = 1; j < A_co.length; j++){
if(A_co[j].contains(B)){
temp = A_co[j].split(":");
... |
3a073390-4629-42b6-ba1f-a839369e6532 | 2 | @Override
public Square[][] move(Square[][] theBoard, char c)
{
Location l1 = parsingInts();
while (theBoard[l1.getX()][l1.getY()].getPiece() != c)
{
System.out.println("That's not one of your pieces. Give the coords of your pieces.");
l1 = parsingInts();
... |
f5e3a6fe-9514-463b-a0a0-0e39fbd98003 | 7 | public static NaturalNumber ReadFromString(String s, int radix)
{
NaturalNumber n;
int i;
char a[];
n = new NaturalNumber(0);
if(n == null)
{
return null;
}
a = s.toCharArray();
for(i = 0;
i < a.length && (NaturalNumber.IsDigit(a[i], radix) ||
a[i] == ',');
... |
e2c40b13-1ed7-4b2d-9be4-165ac9ada5ba | 5 | public void keyReleased(KeyEvent e) {
int keyCode = e.getKeyCode();
switch(keyCode) {
case KeyEvent.VK_W :
bu = false;
break;
case KeyEvent.VK_S :
bd = false;
break;
case KeyEvent.VK_A :
bl = false;
break;
case KeyEvent.VK_D :
br = false;
break;
case KeyEvent.VK_J :
sv.ml... |
49635945-1a78-4779-b143-d4e023a1d8ff | 5 | public boolean arrayInOrder(int[] array, int flag) {
for (int i = 0; i < array.length - 2; i++) { // i is from 0 to 2nd last
if ((flag == 0 && array[i] < array[i + 1])
|| (flag == 1 && array[i] > array[i + 1])) {
return false;
}
}
return true;
} |
7e9ba57b-571c-46cf-bde0-2b2e0c0ad70c | 6 | public int getAdjacentColumn(int rotation, int column) {
switch(rotation) {
case Hex.UP_RIGHT:
case Hex.DOWN_LEFT:
return column;
case Hex.UP_LEFT:
case Hex.LEFT:
return column - 1;
case Hex.DOWN_RIGHT:
case Hex.RIGHT:
return column + 1;
default:
return -1;
}
} |
1a38f04a-4c4d-4cb3-9bec-984be7bae5f9 | 5 | @SuppressWarnings("unchecked")
public static final <T> T[] removeFirst(T[] array, T item, boolean preferNull) {
if (array == null || array.length == 0) return array;
final int index = indexOf(array, item);
if (index < 0) return array;
if (preferNull && array.length == 1) return null;
return remove((Class<T>)... |
1d869c3a-4191-495a-b044-8b6200fe7d0f | 1 | @Override
public String execute(SessionRequestContent request) throws ServletLogicException {
new CountryCommand().formCountryList(request);
City currCity = (City) request.getSessionAttribute(JSP_CURRENT_CITY);
if (currCity != null) {
request.setAttribute(JSP_CURR_ID_COUNTRY, cur... |
dd489948-0933-4bfd-86da-bc4d747988a6 | 5 | private boolean checkVertical(CellState player, int col, int row) {
// TODO das muesste doch auch funktionieren wenn man das aktuell
// gesetzen feld nicht ueberprueft, weil da
// ohnehin der aktuelle spieler drin steht...
// dann koennte man auch mode.getwinlength()-1 verwenden, oder?
// check downwards
... |
cb5764a2-2799-41e0-a9db-a419db073dd7 | 1 | protected String convertStreamToStr(InputStream is) throws IOException {
Writer writer = new StringWriter();
char[] buffer = new char[1024];
try {
Reader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
int n;
while ((n = reader.read(buffer)) !... |
cce89f75-60f3-41eb-85f6-0658665976d9 | 7 | public static void main(String [] args) {
// dynamic programming, backtracking from lower right to top left
// we'll do this carefully, in place, n the map array
for (int i=SIZE-1; i>=0; i--) {
for (int j=SIZE-1; j>=0; j--) {
int downDist = Integer.MAX_VALUE;
int rightDist = Integer.MAX_VALUE;
if (... |
7d99b73b-8b3d-4b63-9589-76583b494bfb | 9 | public YoutubeStreamUrl(final String data) throws DecoderException {
URLCodec urlCodec = new URLCodec();
String[] splitData = data.split("&");
for (String s : splitData) {
if (s.contains("url=")) {
url = urlCodec.decode(StringUtils.substringAfter(s, "="));
... |
0bd66448-a3a1-4c2a-9667-212109a7f4fc | 3 | public void spawnPlayerWithLoadedChunks(EntityPlayer var1) {
try {
NBTTagCompound var2 = this.worldInfo.getPlayerNBTTagCompound();
if (var2 != null) {
var1.readFromNBT(var2);
this.worldInfo.setPlayerNBTTagCompound((NBTTagCompound) null);
}
... |
c892a86e-82c7-468f-80b8-532526fb8db8 | 7 | @Override
public void perform(byte[] bytes) {
if ((bytes != null) && (bytes.length != 0)){
BitSet bits = BitSet.valueOf(bytes);
bitsNumber = bytes.length*8;
if (header){
bits = processHeader(bits);
}
gotBits += bitsNumber;
for (int i = 0; i < bitsNumber; i++){
codePart.set(partBits, ... |
9c3e081d-b4f0-47db-9d94-8239b3dad86d | 9 | private Update update() {
switch (peekType()) {
case MEM: {
consume(MEM);
consume(LBRACKET);
Expression idx = expression();
consume(RBRACKET);
consume(ASSIGN);
Expression val = expression();
return new Update(idx, val);
}
case ABV_MEMSIZE:
case ABV_DEFENSE:
case ABV_OFFENSE:
case ABV_... |
bd19c013-7e20-4dc6-ac92-766679333b4d | 6 | public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
Position other = (Position) obj;
if (orientation != other.orientation) {
return false;
}
if (x != other.x) {
return false;
}
... |
6a215c5d-bf5c-4a7a-b944-79657349426a | 0 | public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
} |
fb825e82-d759-4647-8cbf-10fee80d5381 | 9 | private int decodeLoopStyle(char[] str) {
if (str.length == 0) {
return 0;
}
int[] counts = new int[str.length];
for (int i = counts.length - 1; i >= 0; i--) {
if (i == counts.length - 1) {
counts[i] = canDecode(str, i, i) ? 1 : 0;
} else if (i == counts.length - 2) {
counts[i] = (canDecode(str... |
cdc02844-0366-439f-9536-57f34496b61a | 4 | public static void fermeture() {
if ((fenetrePrincipale != null && !fenetrePrincipale.isDisplayable())
&& (fenetreNouvellePartie != null && !fenetreNouvellePartie.isDisplayable())) {
quitter();
}
} |
29722dd5-b2ce-4a69-87b2-15820ba46f8f | 5 | static public byte[] encode(byte[] in)
{
byte[] out = new byte[20000];
int i, j, bitat, outlen, firstByte;
long t;
bitat = 0;
for(i = 0;i < in.length;i++)
{
t = huffLookup[unsigned(in[i])].bits;
for(j = 0;j < huffLookup[unsigned(in[i])].len;j++)
{
putBit(out, bitat + huffLookup[unsigned(in[i])... |
42eb98a5-0816-46ce-860c-41453677c811 | 4 | public void gravity() {
// - Détection des trous dans matrix (valeurs 0)
// - Décalage en colonne des boules situées au dessus des trous
for (int j = 0; j < 8; j++) {
int k = 7;
for (int i = 7; i >= 0; i--) {
if (matrix[i][j] != 0) {
matrix[k][j] = matrix[i][j];
k--;
}
}
for (int i =... |
c09e3d87-2bd7-4d3d-bff6-41957e629c1b | 1 | @Override
public List<String> values() {
List<String> result = new ArrayList<String>();
if (value != null) result.add(value);
return result;
} |
d2f27b66-e80a-411e-a602-38f678235279 | 5 | public int getLine(Object element)
{
if( element instanceof Tree )
{
Tree tree = (Tree) element;
element = tree.getNode();
}
if ((this.contextClass != null) && (this.contextClass.isInstance(element))) {
try
{
return ((Integer)this.contextClass.getMethod("lineStart", new Class[0]).invoke(ele... |
ba9f29cb-d601-4092-bdde-93a2e72a8baa | 7 | public static Callable getPropFunctionAndThis(Object obj,
String property,
Context cx)
{
Scriptable thisObj = toObjectOrNull(cx, obj);
if (thisObj == null) {
throw undefCallError(obj, prop... |
c979379b-74c9-4657-a810-150b1d49dbf1 | 3 | public void setBranding(Path small, Path medium, Path big) {
Path s = handleImage(small, UIResNumbers.BRANDING_SMALL.getNum());
Path m = handleImage(medium, UIResNumbers.BRANDING_MEDIUM.getNum());
Path b = handleImage(big, UIResNumbers.BRANDING_BIG.getNum());
s = s == null ? UIDefaultIm... |
b27b6d19-5cfd-43d0-845e-2e7130e91f0e | 7 | public static File getAppDir(String par0Str)
{
String var1 = System.getProperty("user.home", ".");
File var2;
switch (EnumOSMappingHelper.enumOSMappingArray[getOs().ordinal()])
{
case 1:
case 2:
var2 = new File(var1, '.' + par0Str + '/');
... |
a3d16e10-e3c6-43c0-9435-e906b66276d1 | 8 | public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(true) {
//Drawing the rectangle
float x = sc.nextFloat();
float y = sc.nextFloat();
boolean inFigureWidth = x >= 12.5f && x <= 22.5f;
boolean inFigureHeight = y >= 6f && y <= 13.5f;
boolean inFigureSpace = ... |
d54f2ecd-579d-4b53-a6ef-c7ca4d272ddd | 5 | private void validate() throws RrdException {
if(!ArcDef.isValidConsolFun(consolFun)) {
throw new RrdException("Invalid consolidation function in fetch request: " + consolFun);
}
if(fetchStart < 0) {
throw new RrdException("Invalid start time in fetch request: " + fetchStart);
}
if(fetchEnd < 0) {
th... |
c1d74ebb-df37-48e1-ab9e-5718c2144b0c | 5 | @Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Estado other = (Estado) obj;
if (this.idEstado != other.idEstado && (this.idEstado == null || !this.idEst... |
29223cbe-3540-402c-a033-b3c34de7e92d | 0 | public SkipIterable(Iterable<T> accessor, int count)
{
this._accessor = accessor;
this._count = count;
} |
e5d09ec0-92c4-4c7c-93aa-4bf8b8d49eab | 6 | public static void main(String args[]) {
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
... |
b5f456ea-f315-4e92-a32c-2d8924726668 | 1 | public static boolean circleToCircle(float c1x, float c1y, int c1radius, float c2x, float c2y, int c2radius)
{
float absx = c1x - c2x;
float absy = c1y - c2y;
float abs = absx * absx + absy * absy;
if(abs <= (c1radius + c2radius) * (c1radius + c2radius)) return true;
return false;
} |
fcde8c3a-4522-4054-815c-e6e4a7dd2f99 | 2 | public ManagerReport() {
//setModalExclusionType(ModalExclusionType.APPLICATION_EXCLUDE);
setTitle("停车场经理报表");
setBounds(100, 100, 450, 367);
String txt="";
if(pm.getManagerList().size()==0){
txt = "还未创建停车场经理。";
}
//获取停车场经理
for(int i=0;i<pm.getManagerList().size();i++){
ParkMan... |
b4003c31-697f-40cb-9179-53ad33ad2365 | 3 | private void fillTransmissionModel() {
Vector<String> names = new Vector<String>();
for(String s : Global.getImplementations("models/messageTransmissionModels")) { // default project && current project
names.add(s);
}
if(!names.contains(Configuration.DefaultMessageTransmissionModel)) {
names.add(Configura... |
7dba63c4-0cb3-45fe-bdb5-163a1f7c9b8b | 1 | public void printPatients() {
System.out.println("Patient: " + name + ", age: " + age + ", illness: " + illness);
if (!isLast) {
nextPatient.printPatients();
}
} |
39004935-136e-450f-98c6-c6619371d64d | 4 | public List findConstantsForGuids(List constantGuids)
throws UnknownHostException, IOException, CycApiException {
if ((constantGuids == null) || (constantGuids.size() <= 0)) {
return null;
}
List result = new ArrayList();
// @ToDo this is very inefficient...we need to find a way to do th... |
b6b9647a-3391-4726-8bcf-cb11557945b0 | 6 | private void registerCommands() {
ProxyServer.getInstance().getPluginManager().registerCommand(this, new BungeeSuiteCommand(this));
if (portalsEnabled) {
ProxyServer.getInstance().getPluginManager().registerCommand(this, new SetPortalCommand(this));
ProxyServer.getInstance().getPluginManager().registerComm... |
2fd80b29-996b-463a-8a61-0b9c464b4648 | 9 | public void setBulletType(int type) {
Element[] elem = getSelectedParagraphs();
if (elem == null)
return;
float currentIndent = 0.0f;
AttributeSet as = null;
StyledDocument doc = getStyledDocument();
Element head = null;
Icon icon = null;
for (Element e : elem) {
as = e.getAttributes();
curr... |
e41d5421-1433-4623-9276-2d429ccf23c1 | 0 | public PromotionDialog(Game game) {
this.game = game;
this.setLayout(new FlowLayout());
this.setModal(false);
this.setUndecorated(true);
this.setAlwaysOnTop(true);
this.queenButton.addActionListener(this);
this.knightButton.addActionListener(this);
this.add(this.queenButton, BorderLayout.PAGE_EN... |
fdd8011a-7616-4715-a7e3-760570a4f163 | 2 | public int registerPacket(Class<? extends APacket> p) {
if(!PList.contains(p)) {
PList.add(p);
}
return PList.indexOf(p);
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.