method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
08a12c1d-a186-4399-a1b0-361d4261fb46 | 8 | @Override
public void reduce(Text key, Iterable<Text> values, Context context)
throws IOException
{
String[] arr;
float num1 = -1;
float num2 = -1;
float f;
synchronized (this)
{
if (null == AIDReducer.fs)
{
AIDReducer.fs = FileSystem.get(context.getConfiguration());
}
... |
28b6c8e1-6867-458e-b75a-1e8769435ebb | 1 | public String enkodeRC4(String result)
{
try
{
String text2Encrypt;
byte[] ciphertext1;
ab.system.libraries.security.ABSecurity.ControllEncRC4Engine s1 = new ab.system.libraries.security.ABSecurity.ControllEncRC4Engine();
text2Encrypt = result;
... |
7d0122bc-7a90-486c-b88c-f9e2d19880b1 | 3 | public boolean shipInBounds(Ship ship)
{
for(int x = ship.x; x < ship.x+ship.xSize; x++)
for(int y = ship.y; y < ship.y+ship.ySize; y++)
if(!isTile(x,y))
return false;
return true;
} |
85cdfaf5-d8c8-4ecb-8b0f-6d5e3dd42b57 | 9 | private static void mergeSort(WoodInterface[] src, WoodInterface[] dest, int low,
int high, int off) {
int length = high - low;
// Insertion sort on smallest arrays
if (length < INSERTIONSORT_THRESHOLD) {
for (int i = low; i < high; i++)
for (int j = i; j > low
&& (dest[j - 1]).compareTo(dest[j].... |
35d4b3b2-bcb9-4c85-b28e-2e911de3fe1d | 7 | public String toString(Collection<State> states, String[] alphabet,
State starting) {
int maxCellLen = 0;
for (State state : states) {
if (state.name().length() > maxCellLen) {
maxCellLen = state.name().length();
}
List<String> eachStateMovesList = state.movesStringList();
for (String eachMove : ... |
75133ba0-d1d4-4e40-b417-40060029da6f | 1 | public void completeAll() {
do {
completeStep();
} while (step != FINISHED);
} |
4b7d7c94-9ae7-4efc-81dc-b9cbb6c2cf1a | 1 | public Server(int port, String locationIP) {
ip = locationIP;
try {
serverS = new ServerSocket(port);
} catch (IOException e) {
e.printStackTrace();
}
} |
d32a77b2-b618-4fa6-ab2d-f376903e945b | 9 | public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
StringBuilder out = new StringBuilder();
int nCase = Integer.parseInt(in.readLine().trim());
for (int t = 0; t < nCase; t++) {
in.readLine();
if (t != 0)
out.append("\n... |
ac0c82d9-4982-49bc-b1f8-21e0389d1868 | 3 | public boolean jsFunction_waitEndProgress(int timeout) {
deprecated();
int curr = 0; if(timeout == 0) timeout = 10000;
while(JSBotUtils.hourGlass)
{
if(curr > timeout)
return false;
Sleep(25);
curr += 25;
}
return true;
} |
08418415-e47d-4a90-94e6-b6765da22a6c | 1 | public void initCommands() {
LOGGER.debug("method initCommands starting...");
// 1. Initialize the standard commands
exitCommand = propertiesLoader.loadProperty(Constants.MAIN_EXIT_COMMAND);
helpCommand = propertiesLoader.loadProperty(Constants.MAIN_HELP_COMMAND);
commands = new HashMap<String, Command>();
... |
0c7bc5a6-0cae-47e4-93b0-a1e0d7329060 | 2 | private String getFileToOpen() {
JFileChooser projectFC = new JFileChooser();
int validPath = projectFC.showOpenDialog(myCP);
if (validPath == JFileChooser.ERROR_OPTION || validPath == JFileChooser.CANCEL_OPTION) {
return null;
} else {
return projectFC.getSelectedFile().toString();
}
... |
e9077ff4-1b4b-47cc-98f0-2f0d8b2570f9 | 1 | protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) {
return("Lexical error at line " +
errorLine + ", column " +
errorColumn + ". Encountered: " +
(EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(... |
5d1aa014-6155-4fbe-b9e3-f6928c5b590a | 4 | public void mousePressed(MouseEvent e) {
if(Global.isRunning) { return; } // block mouse input while simulating
if(e.getButton() == MouseEvent.BUTTON1) { // translate the view
shiftStartPoint = e.getPoint();
setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
} else if(e.getButton() == MouseEvent.BUT... |
240b120f-7912-4c5a-a3da-d30a90d2cbca | 5 | @Override
public int hashCode() {
int hash = 5;
hash = 97 * hash + (this.name != null ? this.name.hashCode() : 0);
hash = 97 * hash + (this.supportedTypes != null ? this.supportedTypes.hashCode() : 0);
hash = 97 * hash + (this.required ? 1 : 0);
hash = 97 * hash + (this.notNu... |
4ab0baf7-5ab0-439b-9b05-4b25a50f98c8 | 7 | @Override
public String toString() {
// Alignment not performed
if (score == null) return "";
char matching[] = new char[alignmentA.length];
for (int i = 0; i < alignmentA.length; i++) {
if ((alignmentA[i] == ' ') || (alignmentB[i] == ' ') || (alignmentA[i] == '-') || (alignmentB[i] == '-')) matching[i] =... |
bc72266e-3ece-466d-b7d4-e2519245e043 | 3 | private static boolean isAllDataValid(TreeMap<Float, float[]> value) {
for (float[] f : value.values()) {
for (float f1 : f) {
if (f1 != f1) {
return false;
}
}
}
return true;
} |
e30d6fd1-fc51-4add-94eb-3d7ff3761754 | 0 | public int size() { return N; } |
30276f0e-7e89-4093-b82a-91c5cd23689b | 2 | private void btnEliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEliminarActionPerformed
int filaseleccionada = tablaRegistrar.getSelectedRow();
if(filaseleccionada>=0)
{
if(JOptionPane.showConfirmDialog(null, "Esa seguro de eliminar")==0){
... |
22ca8963-f026-4331-951d-104ecac5dec8 | 0 | @Override
public String getJarName() {
return jarName;
} |
05e9c826-beec-445d-b081-ab558120b761 | 4 | public Map<Integer, List<String>> getFolderContentsInfo(String folderName) {
Map<Integer, List<String>> map = new HashMap<Integer, List<String>>();
ArrayList<String> result = new ArrayList<String>();
//Folder root = session.getRootFolder();
Folder root = null;
if (!folderName.eq... |
e030a97a-38ba-45d1-8d02-a9b354c89fa0 | 5 | public List<Integer> verifyVotes(List<Integer> u_votes, int user_id){
List<Integer> accepted=new LinkedList<Integer>();
Iterator<Integer> it=u_votes.listIterator();
while(it.hasNext()){
Integer i=it.next();
if(!tempCandidates.contains(new Candidate("","",i))){
continue;
}
if(votes.get(user_id).con... |
4f9dde1e-af7e-4435-adb8-75b088414af4 | 0 | @Override
public void componentMoved(ComponentEvent e) {
} |
8b5398d8-a21a-4dc6-a318-201cbddad52a | 9 | @Override
public void removerUsuario(){
if ( this.num_usuarios == 0 ) System.out.println("\nNão existem "
+ "usuários.");
else{
System.out.println("\nQual dos usuários você gostaria de remover? "
+ "[ 1 - " + this.num_usuarios + " ]" );
int... |
72f48c69-24ff-41d9-bd20-04c5476121ed | 3 | @Override
public void execute(CommandSender sender, String worldName, List<String> args) {
this.sender = sender;
if (worldName == null) {
error("No world given.");
reply("Usage: /gworld setinventorygroup <worldname> <groupname>");
} else if (!hasWorld(worldName)) {
reply("World not found: " + worldNa... |
500392e4-1ce6-4df1-bd86-bbdca0e2b67e | 0 | public ConnectionInfo getConnectionInfo() {
return connectionInfo;
} |
f86b234c-1cc6-4463-9872-c4e6e8eeb345 | 8 | private String toMatrixString(int[][] counts, int[] clusterTotals,
Instances inst)
throws Exception {
StringBuffer ms = new StringBuffer();
int maxval = 0;
for (int i = 0; i < m_numClusters; i++) {
for (int j = 0; j < counts[i].length; j... |
f2c8d17f-9f03-4ad8-bd3f-9a690e37685c | 2 | public static void main(String args[]) {
Scanner s = new Scanner(System.in);
int N, i;
System.out.println("Enter value of N");
N = s.nextInt();
int array[] = new int[N];
System.out.println("Enter " + N + " Elements");
for (i = 0; i < N; i++)
array[i] = s.nextInt();
sorter(array);
System.out.println... |
89b35d75-e98b-454d-aad9-687340053c1d | 9 | public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof DefaultHighLowDataset)) {
return false;
}
DefaultHighLowDataset that = (DefaultHighLowDataset) obj;
if (!this.seriesKey.equals(that.seriesKey)) {
... |
19eb5c8c-8b3d-4080-9e48-7b5bc5b4b742 | 8 | private ConfigurationAreaChangeInformation[] parseConfigurationChanges() throws SAXException, InterruptedException {
final List<ConfigurationAreaChangeInformation> areaChangeInformations = new LinkedList<ConfigurationAreaChangeInformation>();
while(_xmlStream.matchStartElement("konfigurationsAenderung")) {
// ... |
4dc83ce1-162c-4f8f-bc05-89850091dc00 | 6 | public int compareTo(Individual arg) {
// Compare by class name first:
String first = getClass().getSimpleName();
String argFirst = arg.getClass().getSimpleName();
int firstCompare = first.compareTo(argFirst);
if (firstCompare != 0)
return firstCompare;
if (name != null && arg.name != null) {
int seco... |
57defb9a-4e6f-41b7-ac97-ab40d7b5ce8a | 6 | private void handleKeys(int delta) {
Player.p.setSpeed(speed);
if(rotateRight){
Player.p.rotate(delta* 0.1,0);
}
if(rotateLeft){
Player.p.rotate(delta* -0.1,0);
}
if (forward) {
Player.p.moveForward(delta, true);
}
if (backward) {
Player.p.moveForward(delta, false);
}
if (left) {
... |
d4197be3-6eb3-4abe-aee2-629cc721a3c8 | 8 | @Override
public void valitseVuoroToimepide(){
if (r.nextInt(2) == 0){
valinta = Valinta.LUOLASTO;
int r3 = r.nextInt(3);
super.setValittuLuolasto(super.peli.getLuolastot().get(r3));
} else {
valinta = Valinta.KORTTI;
int r3 = r.nextInt(3)+... |
801dbd4b-f430-406c-ab45-5d0234671211 | 6 | public boolean select(final int... ids) {
if (selected() && !selectedIsOnOf(ids)) {
deselect();
}
if (selectedIsOnOf(ids)) {
return true;
}
final Item item = ctx.inventory.select().id(ids).shuffle().poll();
if ((ctx.game.tab() == Game.Tab.INVENTORY || ctx.game.tab(Game.Tab.INVENTORY)) && item.click(... |
a30d0bee-d31a-42ca-8fbc-1c19ee99a821 | 3 | public XMLChecker(String args[]) {
// Get input from the console
String startingPath = ConsoleTools.getNonEmptyInput("Enter starting path: ");
String checkType = ConsoleTools.getNonEmptyInput("Enter check type (v) validate, (w) well-formed: ").toLowerCase();
while (!(checkType.equals(VALID) || checkType.equa... |
52ab358c-b3f8-4948-b4fe-60903dc96e3a | 2 | public void RemoveChannel(String channel)
{
if(VoiceChannels.contains(channel)) VoiceChannels.remove(channel);
if(OpChannels.contains(channel)) OpChannels.remove(channel);
} |
adcf29d8-42a5-48fa-8cad-6ff10f122ecc | 5 | public static void oldOutputANOVAs(GroupedChannels data,
List<String> groupNames, List<Integer> conditions, int numChunks,
int precision) {
// get all condition-group sequences:
ArrayList<GroupedChannels.TaggedDataSequence> allTDSs = data
.getAllSelectedTDSs(groupNames, conditions);
chunkData(allTDSs, ... |
8b3e7b60-54a2-4108-83ab-6c103b072f2f | 6 | @SuppressWarnings("deprecation")
private void parseCommand(CommandSender sender, String... args)
throws EntityEffectError {
Player senderPlayer = (sender instanceof Player ? ((Player) sender)
: null);
Player player = null;
PlayableEntityEffect effect = null;
... |
89a92a3e-a70a-4a4c-81f4-81a8917d7a67 | 5 | public int cdl3WhiteSoldiersLookback( )
{
return ((( ((( (this.candleSettings[CandleSettingType.ShadowVeryShort.ordinal()].avgPeriod) ) > ( (this.candleSettings[CandleSettingType.BodyShort.ordinal()].avgPeriod) )) ? ( (this.candleSettings[CandleSettingType.ShadowVeryShort.ordinal()].avgPeriod) ) : ( (this.cand... |
cb72a139-cbba-434b-81dd-ec792bef7ced | 8 | public void run() {
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();
// extract numbers, this is the node coun... |
cc8a3e97-6b52-47b5-96f6-07c8232a6c18 | 7 | private byte[] getSound(String fileName) {
try {
URL url = Talker.class.getResource(fileName);
AudioInputStream stream = AudioSystem.getAudioInputStream(url);
AudioFormat format = stream.getFormat();
if ((format.getEncoding() == AudioFormat.Encoding.ULAW)
|| (format.getEncoding() == AudioFormat.Enco... |
e891901b-397c-46d1-8bd4-03d29a50ed9f | 6 | private void computePrimeFactors() {
long X = N;
long i;
for (i = 2; i != 1 && i * i < X; i++) {
if (X % i == 0) {
primes[primeCount++] = i;
do {
X /= i;
} while (X % i == 0);
}
}
if (X !=... |
47362d1e-5388-44ef-9897-64e5c8f3020b | 7 | public static void isiTabel(){
final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
final String DB_URL = "jdbc:mysql://localhost/perpus";
// Database credentials
final String USER = "root";
final String PASS = "";
Connection conn = null;
Statement stmt = null;
... |
700d8348-2dc7-465d-8fc1-849f1ebcfc02 | 4 | public void createNodes(OpdrachtCatalogus opdrachtCatalogus){
top.removeAllChildren();
try {
DefaultMutableTreeNode opdracht = null;
List<Opdracht> opdrachten = opdrachtCatalogus.getOpdrachten();
for(Opdracht o : opdrachten){
String nameOpdracht = o.toString();
opdracht = new DefaultMutableTre... |
d13b0ae4-53ff-4613-85f8-775c6596208d | 5 | public static void setupConsoleLogging() {
Logger rootLogger = getRootLogger();
consoleHandler.setLevel(Level.ALL);
consoleHandler.setFormatter(new Formatter() {
private StringBuffer recordBuffer = new StringBuffer();
private DateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS Z");
... |
35994687-aab6-497e-ac02-944c2db454d9 | 4 | public void sendKeyData() {
PlayerManager playerManager = registry.getPlayerManager();
if (playerManager != null) {
Player p = registry.getPlayerManager().getCurrentPlayer();
if (p != null) {
UDPKeys uk = new UDPKeys(
p.getId(),
... |
57858717-cbad-4580-88a2-1657e6c6a1b3 | 4 | void notifyListeners(Object created, Page modified) {
for (TreeModelListener l : modelListeners) {
if (created != null) {
TreeModelEvent e = null;
if (created instanceof Name) {
e = new TreeModelEvent(this, ((Name)created).getPath());
... |
ae0d873c-7da7-4092-b198-1351052ddb38 | 4 | public void setData(int x, int y, int val) {
if (x < 0 || y < 0 || x >= w || y >= h) return;
data[x + y * w] = (byte) val;
} |
b7e5faed-b6a9-468a-a11f-7ad8d35d82bd | 8 | public JavaScriptObject getJsObject() {
JavaScriptObject jsObj = JsoHelper.createObject();
if (tag != null)
JsoHelper.setAttribute(jsObj, "tag", tag);
if (id != null)
JsoHelper.setAttribute(jsObj, "id", id);
if (cls != null)
JsoHelper.setAttribute(jsObj, "cls", cls);
if (style != null)
JsoHelper.s... |
ea0f08c0-354c-4f49-8896-e9e416bbd8ab | 7 | private NearbyPlace toNearbyPlace(RequestBean request, SearchLocation location)
throws CitysearchException {
NearbyPlace nearbyPlace = new NearbyPlace();
String addr = Utils.getLocationString(location.getCity(), location.getState());
nearbyPlace.setStreet(location.getStreet());
... |
86ec50d5-6344-4d0a-952d-82308214a2b9 | 7 | public static void main(String[] args) throws IOException {
StreamTokenizer st = new StreamTokenizer(new BufferedReader(
new InputStreamReader(System.in)));
while (st.nextToken() != StreamTokenizer.TT_EOF) {
int n = (int) st.nval;
if (n == 0)
System.out.println("NULL");
else {
int[] array = new... |
f82968cd-fe1e-4bef-b508-fce23fe54297 | 3 | private void figthButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_figthButtonActionPerformed
//Set Rounds from textflield
rounds = 0;
try {
rounds = Integer.parseInt(throwsPerTextField.getText());
} catch (NumberFormatException e) {
extraT... |
298e050a-eef0-4e6e-b0b8-e971108189d9 | 4 | public static Point[] generateControls(final int sx, final int sy, final int ex, final int ey, int ctrlSpacing, int ctrlVariance) {
final double dist = Math.sqrt((sx - ex) * (sx - ex) + (sy - ey) * (sy - ey));
final double angle = Math.atan2(ey - sy, ex - sx);
int ctrlPoints = (int) Math.floor(dist / ctr... |
93f2f2ce-067e-475b-89e4-4eda1afe3cf7 | 8 | public void actionPerformed(ActionEvent ae){
if (ae.getSource() == addEmp){
for (int i = 0; i < 6; i++){
int n = 0;
int x = 0;
int y = 0;
if (i == 0){
n = 5;
x = 0;
y = 2;
newTextField = new JTextField(n);
g.anchor = GridBa... |
0071d57e-4af0-4b3c-a351-be5d017e603a | 7 | private void addAndRemoveButton(boolean justRemove)
{
boolean added = false;
for (Iterator<CButton> it = FileWalker.getInstance().getSetButtons().iterator(); it.hasNext();)
{
CButton cButton = it.next();
if (cButton == button)
{
it.remove();
if (justRemove)
retu... |
86867d77-0b0b-460e-89ec-21b8aec9624c | 6 | @Override
public void drawSolutionk(Graphics drawingArea, int... arg) {
int diameter = arg[2];
int x = arg[0];
int y = arg[1];
int depth = arg[3];
int toDraw = DRAW_ALL;
if(arg.length == 5){
toDraw = arg[4];
}
if(depth == 0){return;}
drawingArea.drawOval(x - diameter/2, y - diameter/2, diam... |
d46f290c-06a1-4714-9aff-319c4d788e02 | 6 | public void welcome() {
while (!finished) {
str = "";
int selection = 0;
System.out
.println("------------------------------------------------------");
System.out
.println("Welcome to the new and improved Contact Manager Pro!");
System.out.println("What would you like to do?");
System.... |
a8fe7fb3-b72f-49e3-b55e-3c0ef5f4f26c | 9 | public static int wordLadder(String start, String end, Set<String> dict) {
if(start == null || end == null) {
return -1;
}
if(dict == null) {
return start.equals(end) ? 0 : -1;
}
LinkedList<String> queue = new LinkedList<>();
Map<String, String>... |
685dd48e-a8a1-4936-8e47-822f9fdf046e | 3 | private String DNS_resolve()
{
@SuppressWarnings("unchecked")
LinkedList<Packet> buf = (LinkedList<Packet>) this.buffer.clone();
Iterator<Packet> itr = buf.iterator();
Pattern p = Pattern.compile("addr (\\d+\\.\\d+\\.\\d+\\.\\d+)");
//procura uma requisição DNS na lista de pacotes recebidos
while (itr.has... |
8abf46ef-f931-48ec-b175-a65a7001c8b3 | 1 | public void clearmemory(){
for(int i=0;i<65536;i++)
memnc[i]=0;
} |
51027567-0b3c-43e5-b348-9da2ca0c51d7 | 2 | public Pearson(UserPreferences user1, UserPreferences user2) {
userId1 = user1.getUserId();
userId2 = user2.getUserId();
intersection(user1, user2);
if (itemIds.length == user1.getItemIds().length && itemIds.length == user2.getItemIds().length) {
return;
}
pearson = calculatePearson();
calculateWeights... |
bb1f6aec-d14a-407f-aa20-bc766c011a15 | 0 | public void enqueue(E element) {
queue.insert(element);
} |
11407550-b42f-47c7-bf5b-35edc6a481bb | 5 | public void render() {
for (int c = 0; c < textElements.size(); c++) {
UITextElement text = textElements.get(c);
text.print();
}
for (int c = 0; c < boxElements.size(); c++) {
UIBoxElement element = boxElements.get(c);
element.draw();
}
... |
2a8ee157-3397-4ff3-b417-fffd5499b2f1 | 6 | public int getComboBox3 () {
if (jComboBox3.getSelectedIndex() == 0) return 10;
else if (jComboBox3.getSelectedIndex() == 1) return 50;
else if (jComboBox3.getSelectedIndex() == 2) return 100;
else if (jComboBox3.getSelectedIndex() == 3) return 250;
else if (jComboBox3.getSelec... |
246a059d-1884-4bd0-891a-a35ec190af82 | 7 | public String get(int searchID) {
if(searchID == 0) throw new IllegalArgumentException("Illegal Key: " + searchID);
try {
// Execute a query
this.stmt = this.conn.prepareStatement("SELECT v FROM api_results WHERE k=?");
this.stmt.setInt(1, searchID);
ResultSet rs = this.stmt.executeQuery();
... |
3d114f42-1f36-4761-b53e-ad70830d5ddd | 9 | public void update() {
if (this.parent1 != null) {
this.parent1.child = null;
}
if (this.parent2 != null) {
this.parent2.child = null;
}
if (this.node1 != null) {
this.parent1 = this.node1.getPotential();
}
if (this.node2 != null) {
this.parent2 = this.node2.getPotential();
}
if (this.pa... |
4b371a1c-71cd-48b9-8c93-2479b83dd7ba | 6 | private void rb_insert_fixup(RBNode z) {
// makeDotFile();
// com.andreydev.rbtree.RBNode y;
RBNode y = nil;
while (z.getParrent().getColor() == Color.RED) {
if (z.getParrent() == z.getParrent().getParrent().getLeft()) {
y = z.getParrent().getParrent().get... |
064c2abc-88eb-4b8c-8c2e-39477eb79e1c | 8 | public boolean initialiseWithLines(ArrayList<StringBuffer> lines, ProcessingOptions options) throws UnsupportedEncodingException {
//remove blank rows at the bottom
boolean done = false;
int i;
for(i = lines.size() - 1; !done; i--){
StringBuffer row = lines.get(i);
if(!StringUtils.isBlank(row.toString())... |
d3b46372-556f-4381-aba5-5ea8976bff7a | 1 | public AnnotationVisitor visitAnnotation(final String desc,
final boolean visible) {
return new SAXAnnotationAdapter(getContentHandler(), "annotation",
visible ? 1 : -1, null, desc);
} |
11b58b23-f63f-4dc9-90cb-b86915e5fc6d | 6 | protected OgexCameraNode toCameraNode( DataStructure ds, Map<BaseStructure, Object> index ) {
OgexCameraNode result = (OgexCameraNode)index.get(ds);
if( result != null ) {
return result;
}
result = new OgexCameraNode();
index.put(ds, result);
configureNode(res... |
66704dc2-e324-4558-a659-4ba65222826f | 8 | public static void main(String[] _args) {
final int NUMELEMENTS = 40;
double[] inArray = new double[NUMELEMENTS];
double[] outArray = new double[NUMELEMENTS];
// initialize inArray
for (int i=0; i<NUMELEMENTS; i++) {
inArray[i] = (double)i;
}
String sourceFileName = "SquaresDbl.hsail";
String squ... |
5883908c-3f0a-4c03-85d0-09c86b4578a6 | 3 | public boolean canBuyDevCard(){
if(resources.getOre()>0&&resources.getSheep()>0&&resources.getWheat()>0){
return true;
}
return false;
} |
18405b8a-0dd5-43c6-acbb-b4e95a9b2447 | 5 | public void handleBattleMenuInput(){
boolean safeChoice = false;
String userChoice;
while(!safeChoice){
System.out.println("Command: ");
userChoice = input.nextLine();
if(userChoice.compareTo("Melee") == 0 || userChoice.compareTo("melee") == 0){
Battle battle = new Battle();
safeChoice =... |
a521dda5-83e4-4bf3-b21d-02705a6455cb | 7 | public static String intelligentCapitalize(String pText)
{
boolean lDoCap = false;
final StringTokenizer lST = new StringTokenizer(pText, ".- ", true);
final StringBuffer lSB = new StringBuffer(50);
while(lST.hasMoreTokens())
{
String lWord = lST.nextToken();
if(lWord.equals(".") || l... |
eb182092-cb33-40c9-8d10-c1604ef338d8 | 6 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (this.getClass() != obj.getClass() || obj == null)
return false;
Edge e = (Edge)obj;
return (n1 == e.n1) && (n2 == e.n2) ||
(n2 == e.n1) && (n1 == e.n2); // TODO should i support multigraphs? beacuse currently i excl... |
e34ecb91-8f5a-45c1-8bc6-0f259da03316 | 8 | protected void cellDrawn(mxICanvas canvas, mxCellState state,
Object element, Object labelElement)
{
if (element instanceof Element)
{
String link = getLinkForCell(state.getCell());
if (link != null)
{
String title = getToolTipForCell(state.getCell());
Element elem = (Element) element;
if... |
c493fb49-3823-47d7-bea0-8d18ad560159 | 9 | public static void gcd2rgb(byte[] gcdPlane, int[] rgbPlane) {
for (int i = 0; i < gcdPlane.length; i++) {
switch (gcdPlane[i]) {
case cORANGE:
rgbPlane[i] = Color.ORANGE.getRGB();
break;
case cCYAN:
rgbPlane[i] = Color.CYAN.getRGB();
break;
case cBLUE:
rgbPlane[i] = Color.BLU... |
1b27068e-e41b-4eb7-80c9-b7c5dddac828 | 2 | public void end() {
if (position=='B') { position='U'; }
else if (position=='I') { position='E'; }
} |
630636a2-27f0-4f5e-9114-8837fb998639 | 5 | public boolean contains(Tile loc) {
HashSet<Tile> tiles = cols.get(loc.getX());
if (tiles != null) {
for (Tile t : tiles) {
if (t.getY() > loc.getY() || t.getPlane() != loc.getPlane())
continue;
byte[] arr = data.get(t);
if (loc.getY() - t.getY() < arr.length) {
return true;
}
}
}
... |
f4a41e51-67f4-4c8a-9ae6-503270b5b86b | 0 | public void setOrderNumber(String orderNumber) {
this.orderNumber = orderNumber;
} |
55042bf3-0325-43bb-8081-4c02a4f8c19e | 0 | public static void setMaxAge(int newMAX_AGE)
{
MAX_AGE = newMAX_AGE;
} |
fa165ee8-c04a-4fb3-b11e-054677e242f4 | 1 | public void initializeId() {
String string = "";
for (HardwareSetAlternative hardwareSetAlternative : hardwareSetAlternatives)
string += hardwareSetAlternative.getId();
setId(Utils.getHash(string));
} |
8f5b423f-a846-4ffc-acb7-331808eb713d | 8 | private int valorMin( Partida partida, EstatPartida estat_partida, int alfa, int beta, EstatCasella estat_casella,
int profunditat, int profunditat_maxima, EstatCasella fitxa_jugador )
{
Tauler tauler = partida.getTauler();
if ( profunditat == profunditat_maxima || estat_partida == EstatPart... |
c1dc774e-222a-4da9-aa71-8c6cea2c7c38 | 9 | public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof UnorderedPair)) return false;
final UnorderedPair pair = (UnorderedPair) o;
return (((first == null ? pair.first == null : first.equals(pair.first)) && (second == null ? pair.second == null : second.equals(pair.second))) ... |
bee50d85-b087-408b-a260-12b4b79bcfd6 | 9 | public static ListNode reverseKGroup(ListNode head, int k) {
ListNode h = null;
ListNode t = null;
ListNode lt = null;
ListNode p = head;
ListNode q = null;
ListNode hres = null;
int n = k;
while (null != p) {
t = p;
h = null;
while (null != p && n > 0) {
... |
0e34c074-594c-47c8-a3d4-b17ce7250775 | 2 | public String getIntegralByUID(Statement statement,String UID)//根据用户名获取积分
{
String result = null;
sql = "select integral from Users where UID = '" + UID +"'";
try
{
ResultSet rs = statement.executeQuery(sql);
while (rs.next()) {
result = rs.getString("integral");
}
}
catch (SQLException e)
... |
bb642250-02e5-48ce-bc21-d465e554469d | 5 | private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
if (txtMemberID.getText() != "") {
btnEdit.setEnabled(true);
try {
ResultSet rs = DB.myConnection().createStatement().executeQuery("select * from members where MemberID='" + ... |
936a123f-7a16-4536-ba76-58b375b644ed | 8 | public void draw(Graphics2D g2){
if(getyOffset()>0){
g2.drawImage(Tile.dropDownBackground,0,getyOffset()-2*getWidth(),KarpfenGame.WIDTH, getWidth()*2,null);
for(int i=0;i<Skill.getNr();i++){
int addition=0;
if(i==enabledSkill){
g2.drawImage(Tile.dropDownSelected,i*... |
a64e12bd-c818-4638-a549-411db4812d47 | 1 | public Texture loadTexture(String path){
Texture tex = null;
try {
tex = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream(path));
} catch (IOException e) {
e.printStackTrace();
}
return tex;
} |
67003dbb-5d67-43d2-b703-d82e1604d815 | 5 | public void edit() throws Exception {
List<File> l = new ArrayList<File>();
for (Params p : model.getParams()) {
if (p.getFile() != null) {
l.add(new File(p.getFile()));
}
}
if (l.isEmpty()) {
throw new ComponentException("No parameter ... |
a10dceac-7b03-4bc5-ac1a-7fb6d26ba859 | 6 | static void drawTopLine(Graphics2D ctx, Game game, World world) {
if (topLine == null) {
topLine = new BufferedImage(1200, 66, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = topLine.createGraphics();
g2d.setPaint(textures.toTexture(15 * 12, 2));
g2d.fillRect(0, 0... |
c7e3f729-f2ce-420d-b72c-4b8cd3a70bdf | 5 | public void selectAll() {
expandMenu();
for(int i = 0; i < methodTree.getRowCount(); i++) {
TreePath path = methodTree.getPathForRow(i);
if(path == null) return;
DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) path.getLastPathComponent();
if(tre... |
fc5d7018-8d47-4070-bed4-7fc17529cd60 | 4 | protected void updatePowerUps() {
for (int i = 0; i < powerUpList.size(); i++) {
if (powerUpList.get(i).isExpired()) {
powerUpList.remove(i);
}
}
for (PowerUp p : powerUpList) {
p.move();
p.bounceOffWalls();
p.score(pad... |
1e94fce2-2a50-4bf8-89d0-fd3d28d5f907 | 5 | public int getAlignedChar(int iMinusOne,boolean preferHigherIndices)
{
// internally to this package, strings are indexed 1...N, so
// we need to convert from the usual 0...N-1 Java convention
int i = iMinusOne+1;
int bestJ = -1;
double bestScore = -Double.MAX_VALUE;
... |
a11ffc9b-f094-487b-bc77-1638abec5acf | 9 | private void buildPorts() {
int i=0, portIndex=0; // Compteur, numero des tuiles ports.
i = 0;
for (int j: portIndexes) { // Pour chaque tuile mer.
waterTile[i] = (WaterTile) grid[j]; // Ajouter la tuile mer au tableau des tuiles mers.
i++; // Incremente le compteur de tuiles mers.
}
for (i = 0 ; ... |
557d957e-67dc-4394-9850-ff5a4954a64b | 8 | public void printModel(Model pm,String sdfilename, boolean autostart, int line) throws InterruptedException {
if (state.connecting) {
cons.appendText("Still connecting. Please wait until connecting is established.");
return;
}
if (!state.connected) {
cons.appendText("Not connected");
return;
}
sta... |
5a548a1c-2397-4e90-937e-723804d520de | 9 | public boolean fetchAll(InputStream is) throws IOException {
//Decoder dec = new Decoder(sr,0,msglen);
while(true) {
int asrlen = objectLen();
if(DEBUG)System.out.println("Object size="+asrlen+"; Buffer size="+data.length+"; Current size="+length);
if((asrlen>0) && (asrlen>data.length)){
System.out.pri... |
397c5225-c9aa-4145-8367-43320b0b6867 | 2 | @Override
public Channel clone() {
Channel newChannel = new Channel(width, height);
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
newChannel.setPixel(i, j, this.getPixel(i, j));
}
}
return newChannel;
} |
a80c23b9-b9ea-42c8-b454-40ce91f31232 | 4 | public static void printMat(Double[][] mat) throws IOException
{
String matrix = "{";
for (int i = 0; i < mat.length; i++)
{
matrix += "{";
for (int j = 0; j < mat[i].length; j++)
{
if (j != mat[i].length - 1)
matrix += mat[i][j] + ", ";
else
matrix += mat[i][j];
}
if (i != mat.l... |
4b72956c-e6f9-44ce-8aa2-54a18ffeda75 | 3 | private static void sobelFile(String filename, int numIterations,
boolean rle) {
System.out.println("Reading image file " + filename);
PixImage image = ImageUtils.readTIFFPix(filename);
PixImage blurred = image;
if (numIterations > 0) {
System.out.println("Blurring... |
a832e7fb-a5e0-4bd4-8e10-c348d33c207c | 9 | @EventHandler(priority = EventPriority.NORMAL)
public void onPlayerInteract(PlayerInteractEvent E)
{
if (E.getClickedBlock() == null || E.getPlayer().getItemInHand() == null)
return;
if (E.getClickedBlock().getType() == M.conf.PressBlock && E.getAction() == Action.LEFT_CLICK_BLOCK && E.getClickedBlock().ge... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.