method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
93fe5fa7-e5cf-4295-8f3f-b64d2b4a1f5a | 0 | public Map<String, Object> getProperties()
{
return properties;
} |
8fa5c850-7997-4d79-99b1-b9ba1c6d1b8c | 2 | public static Filter classNameMatches( String regex )
{
if ( regex == null )
{
throw new IllegalArgumentException( "Parameter 'regex' must not be null" );
}
if ( regex.length() == 0 )
{
throw new IllegalArgumentException( "Empty 'regex' not allowed" );... |
1945d0d1-b3a0-4f11-97e0-6e044f969153 | 6 | public String setMidiIn(int id)
{
if(_keyboard != null)
{
_keyboard.close();
_keyboard = null;
_midiDevices.setKeyboard(_keyboard);
}
if(id == -1)
{
return "<midi-in>-1</midi-in>";
}
_keyboard = _midiDevices.ge... |
be3a2d04-752c-47ac-89a8-3c4c0d5e2390 | 4 | public void startReceiverThread()
{
new Thread()
{
public void run()
{
String tmp = null;
RadiogramConnection dgConnection = null;
DatagramConnection dgSpamConnection = null;
Datagram dgSpam = null;
... |
89e47f90-304a-442a-b12e-ea5f0567f395 | 8 | public static void qsHelpTick( int lo, int hi, LinkedList<Stock> d ) {
if ( lo >= hi )
return;
int tmpLo = lo;
int tmpHi = hi;
String pivot = d.get(lo).getTicker();
Stock indPiv = d.get(lo);
while( tmpLo < tmpHi ) {
//first, slide markers in as far as possible without swaps
while( d.get(tmpLo)... |
b72de233-e2ea-40df-89dc-0012776df854 | 4 | public boolean collisionSideHelp(Obstacle[][] obs,int i, int j, int l) {
boolean collide = obs[Math.max(i,0)][j].CollisionBot(); // In case of jump above the roof top limit.
if ((y+height)/Obstacle.getHeight()<0)
return false; // feet above the roof ^^
l += Obstacle.getHeight() / 2; // Why ?
while (l<height)... |
93345ccc-8e8d-4594-976a-21c1aad765d6 | 8 | public void keyReleased(KeyEvent e)
{
switch (e.getKeyCode())
{
case KeyEvent.VK_SPACE: // Start/Stop game
if (timer.isRunning())
timer.stop();
else
timer.start();
break;
case KeyEvent.VK_C: // Clear grid
life.clearG... |
14e53f67-8e68-4df7-b08f-0140ef82078f | 5 | public void go() {
up = down = left = right = w_key = a_key = s_key = d_key = false;
if(firstGame) {
gameFrame = new JFrame("Dry Ice Climber");
gameFrame.setSize(SCREEN_WIDTH, SCREEN_HEIGHT);
gameFrame.setLocationRelativeTo(null);
gameFrame.setDef... |
66a74140-f631-45bd-8bff-b6e7dfb9d1ff | 5 | @SuppressWarnings("unchecked")
private void registerPacket(EnumProtocol protocol,
Class<? extends Packet> packetClass, int packetID,
boolean isClientbound) {
try {
if (isClientbound) {
protocol.b().put(packetID, packetClass);
} else {
protocol.a().put(packetID, packetClass);
}
Field mapFiel... |
9e78bbe2-b101-4b2b-b367-70561ac8acb6 | 5 | private static void appendJSONPair(StringBuilder json, String key, String value) throws UnsupportedEncodingException {
boolean isValueNumeric = false;
try {
if (value.equals("0") || !value.endsWith("0")) {
Double.parseDouble(value);
isValueNumeric = true;
... |
7fa34398-366c-4277-a4d8-89834d09757b | 9 | @Override
public void unInvoke()
{
final Physical P=affected;
super.unInvoke();
if((P instanceof MOB)&&(this.canBeUninvoked)&&(this.unInvoked))
{
if((!P.amDestroyed())
&&(((MOB)P).amFollowing()==null))
{
final Room R=CMLib.map().roomLocation(P);
if(CMLib.law().getLandOwnerName(R).length()==0)... |
511bfade-4349-4153-aac3-3caf6bec4611 | 9 | public List<Path> generate() throws IOException {
List<Path> paths = new ArrayList<>();
Map<String, List<Tick>> demomap = new LinkedHashMap<>();
Map<String, String> peeknext = new LinkedHashMap<>();
String previous = null;
for (Tick tick : ticklist) {
List<Tick> ticks;
if (!demomap.conta... |
a778b955-e545-42f2-8669-5d185d254e91 | 6 | private static Map<Integer, Double> addActValue(Bookmark data, Map<Integer, Double> actValues, long baselineTimestamp, boolean resource, double dVal) {
if (!data.getTimestamp().isEmpty()) {
Double newAct = 0.0;
if (resource) {
newAct = 1.0;
} else {
Double recency = (double)(baselineTimestamp - Long.... |
9313419c-5c00-4c79-9aca-74fcc454bb5f | 4 | public int getPieceCount(PieceColor color) {
int count = 0;
for(Piece[] row : pieces) {
for(Piece p : row) {
if(p != null && p.getColor() == color) {
count++;
}
}
}
return count;
} |
992bc2a6-6b67-4594-a51d-e868cf942191 | 9 | public double[] getTrainingValues(LinkedList<Board> gameHistory, TaTeTi.CellValue player) throws Exception{
double[] trainValues = new double[gameHistory.size()];
Iterator it = gameHistory.iterator();
Board board;
TaTeTi.CellValue oponent = player.equals(TaTeTi.CellValue.X) ? TaTeTi.Cell... |
ed87e807-ff52-4142-ab0e-644fd88e39c6 | 6 | protected static boolean addToZip(String absolutePath, String relativePath, String fileName, ZipOutputStream out) {
File file = new File(absolutePath + File.separator + fileName);
System.out.println("Adding \"" + absolutePath + File.separator + fileName + "\" file");
if (file.isHidden())
... |
ceb7af9d-fb59-4f30-bd07-63da484f95ee | 2 | @Override
public void playMonumentCard(IPresenter presenter) {
MoveResponse response=presenter.getProxy().playMonumentCard(presenter.getPlayerInfo().getIndex(), presenter.getCookie());
if(response != null && response.isSuccessful()) {
presenter.updateServerModel(response.getGameModel());
}
else {
Syst... |
880694a1-6c73-4a2d-968b-284c9d916426 | 4 | public Intersection getClosest(Ray r) throws Exception {
Intersection closest = null;
for (Entity o : objects) {
Intersection p = o.findIntersect(r);
if (p == null) {
continue;
}
if (closest == null) {
closest = p;
continue;
}
if (p.getDistance() < closest.getDistance()) {
closest ... |
b36f2361-122c-4343-901f-0ba3f50c2259 | 8 | @Override
public boolean onRead(ByteBuffer sslBuffer)
{
logger.debug("Reading {}", sslBuffer);
int bufferSize = sslEngine.getSession().getApplicationBufferSize();
ByteBuffer buffer = sslByteBuffers.acquire(bufferSize, false);
try
{
out: while (handshaking)
... |
252b2cad-b2e4-4048-8d8a-c40b297f15e3 | 0 | public String getAsset_id() {
return asset_id;
} |
36727de4-e628-4a71-90e1-230900d35f9d | 5 | public static void main(String[] args) {
game = new Game();
Scanner scanner = new Scanner(System.in);
while(!game.isGameOver()) {
System.out.println(game.toString());
int chosenint;
for (chosenint = -10;
chosenint >= Direction.values().len... |
d4f59778-a4d1-4340-bcc9-61a61097dbde | 1 | public void setFrontRightThrottle(int frontRightThrottle) {
this.frontRightThrottle = frontRightThrottle;
if ( ccDialog != null ) {
ccDialog.getThrottle2().setText( Integer.toString(frontRightThrottle) );
}
} |
f3c6d573-219e-4ea2-8e58-096878b615a8 | 3 | public CommandFactory() throws IOException, ClassNotFoundException, IllegalAccessException, InstantiationException {
try(InputStream in = CommandFactory.class.getResourceAsStream("commands.properties")){
Properties p = new Properties();
Reader reader1 = new InputStreamReader(in);
... |
8e8d41bb-3641-4730-91fc-ace673d12188 | 7 | public Packet decompress(Packet packet, PassthroughConnection ptc) {
int stripes = packet.getInt(14) >> 1;
int length = packet.getInt(18 + (stripes << 3));
Packet newPacket = packet.clone(fm);
byte[] buffer = newPacket.buffer;
if(length > bufferLength - 50) {
return null;
}
for(int cnt = 0; c... |
50e9de1f-3e08-41c7-9435-3cc1acc74b2f | 3 | public static Tile getTileAt(int x, int y, World world) {
List<Tile> tiles = world.tiles;
for (int i = 0; i < tiles.size(); i++) {
if (tiles.get(i).position.x == x && tiles.get(i).position.y == y) {
return tiles.get(i);
}
}
return null;
} |
1429f947-4f1e-448e-8294-7e326c31b623 | 2 | public long getLong(int index) throws JSONException {
Object object = this.get(index);
try {
return object instanceof Number ? ((Number) object).longValue()
: Long.parseLong((String) object);
} catch (Exception e) {
throw new JSONException("JSONArray["... |
7e326d7f-d387-4b29-adea-63cd4394d1fd | 3 | public static ArrayList<Kill> findAttacker(ArrayList<Kill> killboard,
String attacker) {
ArrayList<Kill> resultBoard = new ArrayList<Kill>();
for (Kill K : killboard) {
ArrayList<Pilot> attackingPilots = K.gettAttackingPilots();
for (Pilot P : attackingPilots) {
if (P.findAttribute(attacker)) {
r... |
19f8aaca-a94b-4373-85b0-f0cc36626ef7 | 0 | public Long getId() {
return id;
} |
e24d95a2-6005-47d9-9c14-0b600571764f | 7 | private static void group(String regex) {
for (int i = listt.size() - 1; i >= 0; i--) {
Tree t = listt.get(i);
if (!t.isLeaf() && t.text.matches(regex)) {
sortlist.add(t);
fifter(t.getPid());
}
}
for (Tree t : sortlist) {
if (t.isLeaf()) {
List<Tree> tt = new ArrayList<Tree>();
sortMa... |
2d5eae42-e3e8-4a18-a194-0d59cf54769f | 5 | private static boolean isPrimitiveOrString(Object target) {
if (target instanceof String) {
return true;
}
Class<?> classOfPrimitive = target.getClass();
for (Class<?> standardPrimitive : PRIMITIVE_TYPES) {
if (standardPrimitive.isAssignableFrom(classOfPrimitive)) {
return true;
... |
a67cb907-2581-48aa-a77c-f8107e65b570 | 4 | public void generateAllRules() {
for (Entry<Integer, List<ItemSet<V>>> entry : frequentItemSets
.entrySet()) {
// we only do this for itemsets larger 1, it'd be kind of a boring
// rule otherwise now, wouldn't it
if (entry.getKey() > 1) {
System.out.println("Generating rules for level: "
+ entr... |
17712b06-7e02-49e1-99e3-54a413b536c4 | 4 | @Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Knooppunt other = (Knooppunt) obj;
if (this.rij != other.rij) {
return false;
}
... |
1573200b-f687-4988-abda-7ccff8f12a11 | 1 | public static void main(String[] args) {
int personCount = 20;
LiftView liftView = new LiftView();
Monitor monitor = new Monitor(liftView);
Person[] persons = new Person[personCount];
for (int i = 0; i < personCount; i++) {
persons[i] = new Person(monitor);
... |
a398c5ff-24d8-44ae-95e4-884c489fea24 | 4 | private String g_idxname( String f )
{
int l = f.length();
String iext = (( l>4 && f.charAt(l-4) == '.' ) ? f.substring(l-3) : "" );
if( !iext.toLowerCase().equals("idx") ) f += "."+ (ext=="dbf" ? "idx" : "IDX");
return f;
} |
5961410d-2957-4aab-a95e-327e758c0aee | 2 | static public void main(String argv[]) {
try {
String name;
if (argv.length == 1) {
name = argv[0];
} else {
name = "WebColor_Generator.txt";
}
ComplexSymbolFactory csf = new ComplexSymbolFactory ();
Lexer l = new Lexer(new FileReader(name));
l.setSymbolFacto... |
cd0b0482-03eb-4074-a0da-3b60e73463ad | 1 | public void updateRow(int index, Object[] array) {
// data[rowIndex][columnIndex] = (String) aValue;
EntityTransaction userTransaction = manager.getTransaction();
userTransaction.begin();
People updateRecord = peopleService.updatePeople((String) array[0],
(String) array[1], (String) array[2], (String) array... |
283690a5-7ad8-40b6-9e90-1a02829e8cac | 5 | public void insert(int index, String stringItem, Image imageItem) {
if (index > size() || index < 0)
throw new IndexOutOfBoundsException();
ScmDeviceLabel label = new ScmDeviceLabel("item", null, true);
label.selectButtonRequired = true;
label.setText(stringItem);
if ... |
ecfb35ef-8587-4700-85a2-158d919d5880 | 9 | public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_LEFT) { //Presiono flecha izquierda
direccion = 3;
mueveJohn = true;
} else if (e.getKeyCode() == KeyEvent.VK_RIGHT) { //Presiono flecha derecha
direccion = 4;
mueveJohn = true;
... |
3ce99f6d-15ae-4de4-86af-aa0c8e01abcf | 6 | public static MethodSlot stellaFunctionFromProcedure(ComputedProcedure procedure) {
if (procedure.procedureFunction != null) {
return (procedure.procedureFunction);
}
{ Symbol procedurename = procedure.procedureName;
MethodSlot stellafunction = null;
if (procedurename == null) {
p... |
f2898fc4-c21a-4b29-93ee-191d3728084b | 4 | @Override
public double[][] updateVelocities(){
assert(neighbourhood != null && velocities != null && position != null);
double constrictionCoefficient = calculateConstrictionCoefficient();
calculateVelocities();
for(int i = 0; i < velocities.length; i++){
for(int k = 0; k < velocities[i].length; k++)... |
9af98727-2ca6-4ecc-8ad8-b43dfba886d7 | 8 | public String monthAdd(String field)
{
String newField = " ADD ";
String number = "";
for(int i = 1; i <= field.length(); i++)
{
if(isNumber(field.substring(i - 1, i)))
{
number = number + field.substring(i - 1, i);
}
... |
635e50f5-0082-40cb-9550-19f403cef565 | 3 | private ByteBuffer readStream(ByteBuffer buf, PDFObject dict) throws IOException {
// pointer is at the start of a stream. read the stream and
// decode, based on the entries in the dictionary
PDFObject lengthObj = dict.getDictRef("Length");
int length = -1;
if (lengthObj != nul... |
a42b2916-9086-41b2-b62d-6792f81ac75e | 3 | @Override
public Card playTurn(Pile hand, Pile playedCards,
int playerIndexOfWhoStarted) {
// TODO (right now, for the purpose of testing, return any card in hand)
// [Strategy]
// Examine what Cards have been played, and by which Player
// (playedCards is designed such that the first Card in the Pile is th... |
0855ca78-9b94-4624-9e4e-a5074cf8397d | 1 | public static byte[][] generateSubKeys(byte[] key) {
byte[] sourceCD = key;
// Splitst de source array in twee tabellen (C, D)
byte[] permutatedBlock = ByteHelper.permutFunc(sourceCD, permutatieTabel1);
byte[] C = getFirstHalf(permutatedBlock);
byte[] D = getSecondHalf(permutate... |
5a36d01b-90b8-41fc-9024-ac3a6f571761 | 2 | @EventHandler
public void onReload(ServerCommandEvent e){
if(e.getCommand().equalsIgnoreCase("reload")){
for(Player p : Bukkit.getOnlinePlayers()){
p.kickPlayer("[RP] Plugin is reloading!");
}
}
} |
8b599d9e-21fe-4241-8cf5-ebe53f9e378a | 7 | void radb2(final int ido, final int l1, final double in[], final int in_off, final double out[], final int out_off, final int offset) {
int i, ic;
double t1i, t1r, w1r, w1i;
int iw1 = offset;
int idx0 = l1 * ido;
for (int k = 0; k < l1; k++) {
int idx1 = k * ido;
... |
2f5ec943-c53f-4856-adda-2293ab1e7f42 | 4 | private LuaValue push_onecapture(int i, int soff, int end) {
if (i >= this.level) {
if (i == 0) {
return s.substring(soff, end);
} else {
return error("invalid capture index");
}
} else {
int l = clen[i];
if (l == CAP_UNFINISHED) {
return error("unfinished capture");
}
i... |
cd23a2fb-757b-44d9-ba43-e44d22c5d482 | 9 | private static List<PolygonP> transformPointsToPolygon(List<Point[]> polygonPointList){
List<PolygonP> polygons = new ArrayList<PolygonP>();
for(Point[] polygonPoints : polygonPointList){
int min = Integer.MAX_VALUE, max = Integer.MIN_VALUE, height = 0;
for(Point point : polygonPoints){
if(point.y >... |
ea94955b-eae1-4fea-883d-a9a2aefb4a59 | 0 | public void doSomething() {
System.out.println("共通処理 " + LoggerUtils.getSig());
strategy.logic1();
strategy.logic2();
} |
0090c3d6-5cdf-4bbd-974d-ae1021618fcb | 9 | private static Source toSource(Object xml) throws IOException {
if(xml==null)
throw new IllegalArgumentException("no XML is given");
if (xml instanceof String) {
try {
xml=new URI((String)xml);
} catch (URISyntaxException e) {
xml=new ... |
81b8040f-33b9-46ba-9a5d-0ff518d78ec8 | 5 | public Object showInfoTableContent(String listName, String conditions) {
if (!(listName.equals("student_list") || listName.equals("login_list") || listName
.equals("log_list"))) {
listName = "teacher_list;" + listName.split("_")[0];
}
String command2 = "show;" + listName + ";" + conditions;
ArrayList<Str... |
955d5cca-6bea-44cd-b172-8d09db958491 | 2 | public void add(Production production) {
String lhs = production.getLHS(), rhs = production.getRHS();
// Does the RHS already have a unique mapping?
if (rhsToLhs.containsKey(rhs))
throw new IllegalArgumentException(rhs
+ " already represented by " + rhsToLhs.get(rhs));
// Add the production.
Se... |
7cac4151-2a2f-4cee-97bf-9bfaebfd228a | 6 | public static final char next (final int row, final int col,
final char[][] map) {
initMovesRecord(map);
final GameSimulation initGame = new GameSimulation(map);
final NodeForExhaust initNode =
new NodeForExhaust(initGame, SEARCH_DEPTH);
final ArrayList<NodeFo... |
2641ecb5-8560-4d47-ad92-6441cc2ce446 | 8 | public int compare(String o1, String o2)
{
String s1 = (String)o1;
String s2 = (String)o2;
int thisMarker = 0;
int thatMarker = 0;
int s1Length = s1.length();
int s2Length = s2.length();
while (thisMarker < s1Length && thatMarker < s2Length)
{
... |
f1e01c30-cbcc-4402-aee2-09336b414c93 | 9 | public static void main(String[] params) {
String cp = System.getProperty("java.class.path", "");
cp = cp.replace(File.pathSeparatorChar, Decompiler.altPathSeparatorChar);
String bootClassPath = System.getProperty("sun.boot.class.path");
if (bootClassPath != null)
cp += Decompiler.altPathSeparatorChar
+... |
04f4e420-268b-45fc-b8d9-968e1def54e3 | 1 | @SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLayeredPane2 = new javax.swing.JLayeredPane();
jLabel1 = new javax.swing.JLabel();
val_token = new javax.swing.JTextField();
... |
5d0c7b2c-26a0-4eff-98a5-963e71a014d4 | 6 | public Codebook getMostInformativeSubset() {
// Get distance matrix for all basis vectors.
int numVects = basisVectors.getColumnDimension();
double[][] proximity = new double[numVects][];
for(int i = 0; i < numVects; i++){
proximity[i] = new double[i+1];
for(int j = 0; j < i; j++){
proximity[i][j] ... |
fdaacef9-cdf5-42fc-8c21-fc1198c30f1b | 6 | protected com.akamon.slots.model.SymbolSet ParseSymbolSet(SymbolSet xmlSymbolSet) throws SlotModelException {
com.akamon.slots.model.SymbolSet modelSymbolSet = new com.akamon.slots.model.SymbolSet(xmlSymbolSet.name);
for(NaturalSymbol xmlNaturalSymbol : xmlSymbolSet.getNaturalSymbol())
{
... |
a61d4950-8058-423c-ad37-a811a6012025 | 8 | public static void idlOutputAllUnitsToFile(String sourcefile) {
{ String codeoutputfile = Stella.idlMakeCodeOutputFileName(sourcefile);
OutputFileStream codeoutputstream = OutputFileStream.newOutputFileStream(codeoutputfile);
Cons globals = Stella.NIL;
Cons methods = Stella.NIL;
Cons verbati... |
042e6eb7-1c20-4f0f-9058-fc1bb78f86d7 | 0 | public void setUserObject(Object userObject) {
this.userObject = userObject;
} |
f9961daf-cb9f-4bac-846d-ebe51cda14cc | 4 | public static void main(String[] args) throws IOException {
BufferedReader buf = new BufferedReader(
new InputStreamReader(System.in));
String line = "";
StringBuilder sb = new StringBuilder();
int f = 0;
d: do {
line = buf.readLine();
if(line==null || line.length()==0)
break d;
int c = Integ... |
be245a99-8d3b-4089-a302-a5c24ce72187 | 6 | private void resetCanBeAvail(final ExprInfo exprInfo, final Phi phi) {
phi.setCanBeAvail(false);
final Iterator blocks = cfg.nodes().iterator();
// For each phi whose operand is at
while (blocks.hasNext()) {
final Block block = (Block) blocks.next();
final Phi other = exprInfo.exprPhiAtBlock(block);
... |
8db7018e-5a20-4b18-a8d6-95cb1a43718a | 9 | public boolean isFlowerOut(Graph a_graph)
{
//First, see this node.
for(int i = 0; i < m_enemies.size(); ++i)
{
if(m_enemies.get(i).m_type == Sprite.KIND_ENEMY_FLOWER)
{
return true;
}
}
//If not, I have neighbors IN THE SA... |
6d1b5be3-26f3-4fe8-bc53-42dd7eba773a | 3 | @Override
public boolean onBlockActivated(
World world, int x, int y, int z, EntityPlayer player, int i, float j, float k, float l
)
{
if (!world.isRemote)
{
TileEntity te = world.getTileEntity(x, y, z);
if (te == null || player.isSneaking())
r... |
242e37fa-0956-4db1-b4b9-eba0b0b2d0eb | 1 | private boolean isValidIdentityDiscCoverage(Grid grid) {
final int identityDiscCount = getIdentityDiscsOfGrid(grid).size();
if (identityDiscCount * 100 / grid.gridSize() <= 2)
return true;
return false;
} |
ec2caa22-7aeb-49fe-9029-b0fa03a1c13e | 4 | public static Map<AnagramWord, String> findAnagrams(File wordFile) {
Map<AnagramWord, String> anagramList = new HashMap<AnagramWord, String>();
List<AnagramWord> wordList = extractWords(wordFile);
for (AnagramWord word : wordList) {
if (anagramList.containsKey(word)) {
String anagram = anagramList.get(w... |
e56fb77c-1276-4c86-aa77-a3f2cba523a1 | 3 | private List<Keyword> keywordsFromType(KeywordType type, List<Keyword> keywords) {
List<Keyword> res = new ArrayList<Keyword>();
if (keywords == null) {
return res;
}
for (Keyword keyword : keywords) {
if (keyword.getKeywordData().getType().equals(type)) {
res.add(keyword);
}
}
return res;
} |
ebdf967a-96e2-45f1-a9bf-e516b1810eb7 | 7 | SpellGroup getSpellGroup(String strName)
{
SpellGroup grpStore;
for (int i=0;i<vctSpellGroups.size();i++)
{
grpStore = (SpellGroup)vctSpellGroups.elementAt(i);
if (strName.equalsIgnoreCase(grpStore.strName))
{
return grpStore;
}
}
try
{
grpStore = new SpellGroup(strName);
RandomAccess... |
c87a6149-3953-43b8-89ba-e593cafd57b5 | 7 | public int edmons_karp(int s, int t) {
int u, e;
mf = 0;
this.s = s;
Arrays.fill(p, -1);
while (true) {
f = 0;
Queue<Integer> q = new LinkedList<Integer>();
int[] dist = new int[V];
Arrays.fill(dist, INF);
dist[s] = 0;
q.offer(s);
Arrays.fill(p, -1);
while (!q.isEmpty())... |
b7adc6fb-8038-4698-8a92-b425da304e4c | 3 | public void setDisplayOptions (int ordering, int nameForm, int direction) {
// Only update if something has changed.
if (
(currentDisplayOrdering != ordering) ||
(currentDisplayNameForm != nameForm) ||
(currentDisplayDirection != direction)
) {
// store the new values.
currentDisplayOrdering =... |
e49237a9-787c-4872-8ea4-00ec0abeb4ce | 0 | public HBox initHeader(String titleText) {
HBox header = new HBox();
header.setAlignment(Pos.CENTER_LEFT);
header.getStyleClass().add("popUpHeader");
header.setPrefHeight(28);
Button closeBtn = new Button();
closeBtn.getStyleClass().add("close-button");
closeBtn.setPrefSize(16, 16);
closeBtn.setMinSize... |
7ea2591c-9332-423f-92f9-bae8f97212f0 | 3 | public String insertionSort2(String a) {
char[] arr = a.toCharArray();
char tmp;
for (int i = 1; i < arr.length; i++) {
for (int j = i; j > 0; j--) {
if (arr[j] < arr[j - 1]) {
tmp = arr[j];
arr[j] = arr[j - 1];
arr[j - 1] = tmp;
} else
break;
}
}
return new String(arr);
} |
48656651-bd72-4410-8fcc-d6192218e7c6 | 3 | public static String platformToLineEnding(String platform) {
if (platform.equals(PLATFORM_MAC)) {
return LINE_END_MAC;
} else if (platform.equals(PLATFORM_WIN)) {
return LINE_END_WIN;
} else if (platform.equals(PLATFORM_UNIX)) {
return LINE_END_UNIX;
} else {
return LINE_END_DEFAULT;
}
} |
02be234f-6166-428e-a2b6-77f93fe6c522 | 3 | @Override
public void moveItem(String fromPath, String toPath) throws ContentRepositoryException, IOException {
File from = new File(rootDir, fromPath);
File to = new File(rootDir, toPath);
if (from.isDirectory()) {
if (to.isDirectory()) {
FileUtils.moveDirectoryToDirectory(from, to, false);
} else {
... |
d9304c50-6059-4da9-8f23-2a375d4011df | 0 | public static void StartingHall() {
currentRoomName = "Starting Hall";
currentRoom = 1;
RoomDescription = "The room is small, square and made of solid stone. It is cold and there is a ladder " +
"going up through a hatch.";
} |
d5e1129a-ff6d-4065-af61-3a0ca4f37f0e | 2 | public static void unregisterFrame(EnvironmentFrame frame) {
try {
fileToFrame.remove(getPath(frame.getEnvironment().getFile()));
} catch (NullPointerException e) {
// The environment doesn't have a file.
}
environmentToFrame.remove(frame.getEnvironment());
// If there are no other frames open, prompt ... |
6f2a5cd0-8aef-454e-919a-f76530f5b87f | 4 | @Override
public Border getBorderStyle(Side side)
{
switch (side)
{
case TOP:
return topBorder;
case LEFT:
return leftBorder;
case BOTTOM:
return bottomBorder;
case RIGHT:
return right... |
016d73d4-933f-42de-adc9-25e6e611f612 | 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://... |
44b72057-d1d8-45b6-9c98-50e4fd604cf1 | 3 | public synchronized void actualiza(long tiempoTranscurrido){
if (cuadros.size() > 1){
tiempoDeAnimacion += tiempoTranscurrido;
if (tiempoDeAnimacion >= duracionTotal){
tiempoDeAnimacion = tiempoDeAnimacion % duracionTotal;
indiceCuadroActual = 0;
}
while (tiempoDeAnimacion > getCuadro(ind... |
45f3c4b5-d6ec-41df-a101-325e6862d41a | 5 | public static final void main(String... args) {
String bigNumber = "7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722... |
2467d89c-4e16-452d-b99f-47f657f8c20a | 3 | private void createTSPFile(int dimension) throws IOException
{
FileWriter writer = new FileWriter(path, false);
PrintWriter printer = new PrintWriter(writer);
printer.printf("%s" + "%n", "NAME: " + path);
printer.printf("%s" + "%n", "TYPE: TSP");
printer.printf("%s" + "%n", "... |
9997ed60-3b2b-4914-8045-d29589a2f48e | 6 | public ArrayList<ArrayList<Integer>> permuteUnique(int[] num) {
ArrayList<ArrayList<Integer>> result = new ArrayList<ArrayList<Integer>>();
if (num.length == 0)
return result;
if (num.length == 1) {
ArrayList<Integer> onePermute = new ArrayList<Integer>();
onePermute.add(new Integer(num[0]));
result.... |
b8d3165e-d150-4f26-9b57-dd4bd9365dae | 7 | public void crearGrups(FitxerJugadorsOut espases, FitxerJugadorsOut oros, FitxerJugadorsOut copes, FitxerJugadorsOut bastos) {
try {
Jugador j = (Jugador)ois.readObject();
while(!j.esCentinela()) {
switch(j.getEquip()) {
case ESPASES:
... |
c7369880-a052-4b32-9da5-1f6a2adec46c | 4 | public int[] getRoomCoords(MansionArea room) {
int[] coords = {-2, -2};
if(room.equals(start)) {
coords[0] = -1;
coords[1] = -1;
}else {
for(int i=0; i<grid.length; i++) {
for(int j=0; j<grid[0].length; j++) {
if(room.equals(grid[i][j])) {
coords[0] = i;
coords[1] = j;
}
}
... |
67f7816f-9819-4f26-aa2c-c03b184dbebb | 1 | public void incluirNoFim(ContaCorrente conta)
{
if(this.quantasContas >= this.capacidade)
this.aContas[this.capacidade-1] = conta;
else
this.aContas[this.quantasContas] = conta;
this.quantasContas ++;
} |
da7b49ff-0684-4656-aeeb-ff18c5277079 | 7 | public TriTileCoord pointToCoord(Point2D point, TriTileDimension dim) {
final int section_x = (int) (point.getX() / (dim.getSide() / 2.0));
final int sectionPxl_x = (int) (point.getX() % (dim.getSide() / 2.0));
final int coord_y = (int) (point.getY() / dim.getHeight());
final int section... |
bfa9749d-9044-431c-98ef-9dbb681dd1fa | 9 | private JSON urlfetch(URI uri, int protocol, Map<String, String> headers, CharSequence content, boolean sign) {
JSON result = null;
try {
HttpClient httpclient = new DefaultHttpClient();
HttpRequestBase method = null;
if (protocol == GET) {
method = new HttpGet(uri);
} else {
... |
8a5dba63-75c8-47d2-9dc0-eabbfb18af73 | 3 | public static void main(String args[]) throws NumberFormatException, IOException {
int i = 0;
int N = 0;
BufferedReader ob = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter value for N");
N = Integer.parseInt(ob.readLine());
int arr[] = new int[N];
Scanner sc=new Scanner(... |
3da84537-f0b4-4881-99f4-aabe040b48b0 | 6 | @Override
public boolean equals(Object innyObiekt) {
if (innyObiekt == null) {
return false;
}
if (innyObiekt == this) {
return true;
}
if (!(innyObiekt instanceof Towar)) {
return false;
}
Towar innyTowar = (Towar) innyObi... |
9a5f6fab-499f-4578-af51-64faef9f2847 | 2 | public void setInterfaces(String[] nameList) {
cachedInterfaces = null;
if (nameList != null) {
int n = nameList.length;
interfaces = new int[n];
for (int i = 0; i < n; ++i)
interfaces[i] = constPool.addClassInfo(nameList[i]);
}
} |
53828415-76a6-4749-9bbf-0b0114d26188 | 6 | public static void quick(List<Element> list, int start, int end) {
int i = start;
int j = end;
int temp;
// select pivot
int pivot = list.get((start + end) / 2).getValue();
do {
while (list.get(i).getValue() < pivot) {
temp = list.get(i).getNu... |
98cc12f0-0ad6-4a54-aafd-c5ca28a1a53f | 1 | public ShellLink setCMDArgs(String s) {
if (s == null)
header.getLinkFlags().clearHasArguments();
else
header.getLinkFlags().setHasArguments();
cmdArgs = s;
return this;
} |
7be845eb-7a4b-4d2d-b4b0-07edeabdfa8d | 1 | private void jMenuAtividadesAtrasadasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuAtividadesAtrasadasActionPerformed
if (usuarioLogado.getTipo().equals("Gerente")) {
this.atividadesAtrasadas();
} else {
JOptionPane.showMessageDialog(null, "Você não pos... |
975c4e91-651d-4034-bd1b-06ab9480babd | 0 | @Override
public Node getNode() {return node;} |
162b2965-0bec-4c20-abaf-56d5cd387d1f | 1 | private static void initRotate(Composite inComposite, int heightHint) {
final Composite toolbar = new Composite(inComposite, SWT.BORDER);
final Composite imageContainer = new Composite(inComposite, SWT.BORDER);
GridData toolbarGridData = new GridData(GridData.FILL_HORIZONTAL);
toolbarGridData.grabExcessHorizon... |
f24cc107-9e3a-48a8-8d0b-53d50d2253ea | 2 | public String[] getParameterValues(String parameter) {
String[] values = super.getParameterValues(parameter);
if (values==null) {
return null;
}
int count = values.length;
String[] encodedValues = new String[count];
for (int i = 0; i < count; i++) {
... |
9cc762af-a99f-4107-84eb-b8f164e48503 | 8 | protected String toJSONFragment() {
StringBuffer json = new StringBuffer();
boolean first = true;
if (isSetSubscriptionId()) {
if (!first) json.append(", ");
json.append(quoteJSON("SubscriptionId"));
json.append(" : ");
json.append(quoteJSON(getSub... |
1c94e811-7e22-43c9-b583-eec7fc8ca7b2 | 0 | public GraphPanel getGraphPanel() {
return graphPanel;
} |
67d3dc92-7d5d-4735-a53b-18bfe9cd7e66 | 9 | private Point getOrigin(Dimension size, Container target) {
Point origin = new Point();
if (anchor == NORTH_WEST) {
origin.x = 0;
origin.y = 0;
}
else if (anchor == NORTH) {
origin.x = ((target.getWidth() - size.width) / 2);
origin.y = 0;
... |
317d4d34-edf6-4eee-94ff-8d73fa5f06dd | 1 | public static CharacterStorageInventory create(){
if(storageInventory == null){
storageInventory = new CharacterStorageInventory();
}
return storageInventory;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.