method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
c1a44b99-d5be-4a36-b332-b1dc1eed1522 | 8 | public boolean isDisturbed(Packet p) {
Position receiverPos = p.destination.getPosition();
double distanceFromSource = p.origin.getPosition().distanceTo(receiverPos);
double poweredDistanceFromSource = Math.pow(distanceFromSource, alpha);
double signal = p.intensity/poweredDistanceFromSource;
double noi... |
48b09ed2-bb79-4094-bc07-89ee42af8fc0 | 5 | private String getExpressionType(Expr expr){
String type;
if (expr instanceof NumberExpr){
type = "Number";
}else if (expr instanceof LiteralExpr){
type = "String";
}else if (expr instanceof FunctionCallExpr){
String fktName = ((FunctionCallExpr) expr).getFunctionName();
if (fktName.equals("true()")... |
1e6b0976-d2a7-4acb-9b2b-0a38bdc01ada | 6 | public int getLoopLength(BrainFuckCode code, boolean forvardSearch){
int loopLenght = 0;
int numberOfInnerLoops = 0;
int currentPosition = code.getCurrentPosition();
while (currentPosition > 0 && currentPosition < code.getCode().length()){
switch (code.getCode().charAt(curre... |
20c6334c-fcfc-4ba7-a3ad-907ace4adc3c | 8 | private void jTextField1FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextField1FocusLost
if(!nombreAntiguo.equals(jTextField1.getText())){
int i = JOptionPane.showConfirmDialog(frame, "Seguro que quieres cambiar la descripción de la política: "+nombreAntiguo+
"\npor "... |
772f8ccb-b6a8-41e3-9060-392d26bafc5c | 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 Township)) {
return false;
}
Township other = (Township) object;
if ((this.townshipID == null && other.township... |
b4bd4a4b-5d9f-4ee5-a79a-063e6d96667e | 5 | public void calcRow(int step) {
int variableCount = Expression.getVariableCount();
String binaryStep = Integer.toBinaryString(step);
while (binaryStep.length() < variableCount) {
binaryStep = "0" + binaryStep; // " step 2 = '10' but if i have 3 steps i need '010'
}
List<String> steps = new ArrayList<>(Ex... |
5bceef1f-8257-45ca-851c-a51c44485b7e | 2 | public static void unpackConfig(Archive container) {
NpcDefinition.buffer = new Stream(container.get("npc.dat"));
Stream stream2 = new Stream(container.get("npc.idx"));
int totalNPCs = stream2.getUnsignedShort();
NpcDefinition.npcIndices = new int[totalNPCs];
int i = 2;
for (int j = 0; j < totalNPCs; j++) {... |
e8f856c3-f3d5-4323-a4ec-cf371075a173 | 6 | public void refreshTab(int index) {
if (index > -1) {
if (itemsPrice.size() > 0)
priceField.setText(formatter.format(itemsPrice.get(index)));
quantityTextField.setText("1");
if (itemsQuantity.size() > 0) {
availableQuantityField.setText(Integer.toString(itemsQuantity.get(index)));
grandTotalField... |
9e9d94aa-8caa-40d1-ada7-427d79989a63 | 1 | private boolean checkLapsedMillis() {
if (System.currentTimeMillis() - timer > 1000) {
return true;
} else {
return false;
}
} |
b5e79dd8-eeb2-44a3-b7cf-fe4fffb58fbd | 9 | public ArrayList<ArrayList<Integer>> zigzagLevelOrder(TreeNode root) {
ArrayList<ArrayList<Integer>> result = new ArrayList<ArrayList<Integer>>();
ArrayList<Integer> currentLevelValue = new ArrayList<Integer>();
Stack<TreeNode> currentLevelTree = new Stack<TreeNode>();
Stack<TreeNode> nextLevelTree = new Stack<... |
e7b2d841-399a-4525-8340-d8dfcb5d467b | 3 | private void reload() throws IOException {
File f = new File("servers.json");
if(!f.exists()) {
writeServers();
System.out.println(Client.instance.translation.translate("file.created", "servers.json"));
}
servers = new Gson().fromJson(new InputStreamReader(new FileInputStream("servers.json"), Charset.forN... |
d25ce23c-e70c-4b3e-b591-8912617b29ce | 9 | @Override
public void paintShape(mxGraphics2DCanvas canvas, String text,
mxCellState state, Map<String, Object> style)
{
Rectangle rect = state.getLabelBounds().getRectangle();
Graphics2D g = canvas.getGraphics();
if (labelGlyphs == null)
{
updateLabelBounds(text, style);
}
if (labelGlyphs != null... |
19c501f1-03c6-474b-80fb-711f327109f4 | 4 | public boolean carOnLane(Car fCar, Lane lane)
{
PathIterator p = fCurve.getPathIterator(null);
FlatteningPathIterator f = new FlatteningPathIterator(p, reduceCarSpeed(fCar.getSpeed()));
while (!f.isDone())
{
float[] pts = new float[6];
switch (f.currentSegment(pts))
{
case PathIterator.SEG_MOVETO:... |
e1925b48-bb42-4f05-a83f-84c5022f7795 | 5 | public static void main(String[] arguments)
{
//ファイルからテキスト群を読み込み
ArrayList<String> texts = ForestExample.loadFile();
//読み込んだテキストからブランチを生成
branches = ForestExample.loadBranch(texts);
//読み込んだテキストからノード生成
nodes = ForestExample.loadNode(texts,branches);
//ルートの設定
roots = ForestExample.loadRoot(nodes);
//ツリ... |
e3273187-0d8b-45ce-b5e9-2221a032ee1e | 4 | private void checkFullHouse() {
if (getNumberOfSuits(1) == 1 && getNumberOfSuits(2) == 1
&& getNumberOfSuits(3) == 1 && getNumberOfSuits(4) == 1) {
myEvaluation[0] = 7;
myEvaluation[1] = hand[0].getValue();
myEvaluation[2] = hand[4].getValue();
myEvaluation[3] = hand[0].getValue();
}
} |
55b1f9a8-4310-4610-8ec7-133accf324a1 | 6 | public static ArrayList<Commands> Sort(ArrayList<Commands> list){
ArrayList<Commands> commands = new ArrayList<>();
for(Commands var1 : list){
if(var1.getCommand().equals("ADD")){
commands.add(var1);
}
}
for(Commands var2 : list... |
6f57cdcf-61a2-421a-835c-3ba398b607c4 | 0 | boolean isEmpty() {
return this.aNotification.size() <= 0;
} |
7b1d40e7-949d-43f7-a408-a4304ee99011 | 6 | private void initGUI() {
try {
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
GroupLayout thisLayout = new GroupLayout((JComponent)getContentPane());
getContentPane().setLayout(thisLayout);
this.setTitle("Tile Puzzle Solver");
pack();
this.setSize(894, 442);
this.setSize(Toolkit.getDef... |
33bbc201-82b7-48af-b00f-f4d5a54f30fc | 5 | private static void createTempJarInner(JarOutputStream out, File f,
String base) throws IOException {
if (f.isDirectory()) {
File[] fl = f.listFiles();
if (base.length() > 0) {
base = base + "/";
}
for (int i = 0; i < fl.length; i++) {
... |
e8509ddc-6a27-4dd9-b8ed-889a2ba014f3 | 4 | public boolean isColliding(GameObject obj){
//If the left side of this is to the left right side of obj and the right side of this is to the right of the left side of obj
if(position.getComponent(0) < obj.position.getComponent(0) + obj.width && this.position.getComponent(0) + this.width > obj.position.getComponen... |
9b20fd10-331c-45fa-acac-8e480a47941d | 2 | public static void main(String[] args) {
ThreadB threadB = new ThreadB();
for (int i = 0; i < 5; i++) {
new Thread(threadB, "线程名称:(" + i + ")").start();
}
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
... |
1037055e-fa9b-463c-bdf5-ebf95c02f200 | 5 | public Object getValueAt(int row, int column) {
TokenType type = editableStyles[row];
switch(column) {
case 0 :
String title = type.toString();
return title.charAt(0) + title.substring(1).toLowerCase();
case 1 :
return EditorStyle... |
4db2726e-d029-4917-a069-42e9fa587188 | 5 | @Override
public void operate(Player player, IncomingPacket packet) {
switch (packet.getOpcode()) {
/*
* Enlists a specified player as a friend.
*/
case 188:
long name = packet.getBuffer().getLong();
player.getPrivateMessaging().addFriendToList(name);
break;
/*
* Removes a specified player ... |
9cf853b0-80f6-44a2-a222-f7b4757ccb92 | 0 | public static void addCard(Map<String, String> user) {
cards.put(user.get("userid"), new Card(gamePanel, user));
gamePanel.setSize(gamePanel.getSize());
} |
cd7b9cb7-d4d0-4a0e-9326-8bf50374652e | 6 | public static int findThreeSumClosest(int[] input, int target) {
// sort the array first
QuickSort.sort(input, 0 , input.length -1);
// set the min value
int minDiff = Integer.MAX_VALUE;
int result = 0;
// iterate from left to right
for( int i = 0; i< input.length... |
2dbc82bd-9644-455d-8cb3-fc001183bb53 | 3 | public Boolean isGameWon(){
for(int i=0;i<getX();i++){
for(int u=0;u<getY();u++){
if(this.cells[i][u]==2048){
return true;
}
}
}
return false;
} |
7abf4362-f440-46d4-9ca2-8b2a125c281b | 3 | public int getAreaSize() {
int rval = 0;
if (type == TYPE_RECT) {
rval = rect.width * rect.height;
}
else if (type == TYPE_CIRCLE) {
rval = (int) ((double)circle_r * (double)circle_r * Math.PI);
}
else if (type == TYPE_POLY) {
rval = getPolygonArea(poly.xpoints, poly.ypoints, poly.npoints)... |
993e1b19-c9e3-4fae-a880-04bdda335767 | 6 | public MC_Location getLocationAtDirection(MC_DirectionNESWUD dir)
{
MC_Location loc = new MC_Location(this);
if(dir == MC_DirectionNESWUD.NORTH) loc.z--;
if(dir == MC_DirectionNESWUD.SOUTH) loc.z++;
if(dir == MC_DirectionNESWUD.WEST) loc.x--;
if(dir == MC_DirectionNESWUD.EAST) loc.x++;
if(dir... |
57a70483-0b12-4a7a-b44c-b3c60aa3a5de | 6 | public void testIllegalCharacters()
{
System.out.println("\nStarting testIllegalCharacters: users");
try
{
new User("RegularName");
}
catch (IllegalArgumentException iae)
{
fail("iae not expected.");
}
try
{
new User("NumbersWithinName3350");
}
catch (IllegalArgumentException iae)
... |
24c15239-d496-4646-b485-035ce20e7c53 | 7 | private ByteBuffer connectClient(String username, String address) {
ClientConnectionLogRecord record = new ClientConnectionLogRecord(
address, SystemEvent.CLIENT_CONNECTION,
"Received connection request from " + address + " for client "
+ username + ".");
LOGGER.log(record);
Connection conn = null;... |
64a594d1-1427-4aae-b771-a02f99a8b085 | 0 | public JTextField getjTextFieldAdresse() {
return jTextFieldAdresse;
} |
5e58e1a6-66e2-4862-9afa-dd93cee89e4b | 9 | private ArrayList<Chord> trackAnalyze(Track track){
ArrayList<Chord> result = new ArrayList<Chord>();
long tick = -1;
int t = 0;
while(t<track.size()-1){
try{
ShortMessage tmp = (ShortMessage) track.get(t).getMessage();
long newTick = track.get(t).getTick();
if (tmp.getCommand()>=144 && tmp.g... |
1d8d1366-64d1-4872-b64c-44322a601f06 | 5 | @Override
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
String Name = request.getParameter("Name");
String City = request.getParameter("City");
String Address = request... |
51c04d89-12d3-46ad-86e2-f8c5e1f6a9fd | 2 | private void btnSaveProfilesMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnSaveProfilesMousePressed
HashMap<String, Profile> profiles = manager.getProfiles();
for (String username : profiles.keySet()) {
try {
profiles.get(username).save();
} catch (IOException e) {
... |
162f985d-6675-48a3-bdec-8a94547fb8f8 | 0 | public String getMessage() {
return "Congrats!";
} |
f323414a-9714-429a-987d-167f2d350142 | 1 | public static boolean isBombed(int x, int y, int[][] sea)
{
return (isHit(x, y, sea) || isMiss(x, y, sea));
} |
b6fa0899-7626-42f6-9f32-8709e06c20fe | 6 | public static Long makeLong( String s) throws Exception
{
long val =0;
if( s.length() > 32)
throw new Exception("Can't encode");
for(int x=0; x < s.length(); x++)
{
char c = s.charAt(x);
if( c== 'A')
{
val =val | ( A_INT << (x*2));
}
else if ( c== 'C')
{
val = val | (C_... |
0bb6e02e-a593-465a-8295-c4da8a80790d | 7 | public static byte[] bytesFromValue(final Value value) throws UnsupportedEncodingException {
byte[] bytes;
switch (value.getType()) {
case NIL:
bytes = new byte[]{NIL};
break;
case BOOLEAN:
if (value.getBooleanValue()) {
... |
d5f8b28f-fbe8-4047-a64f-6c80b89a6cfc | 8 | private float normalize(float x) {
if (x > 315) return 0;
if (x > 225) return 270;
if (x > 135) return 180;
if (x > 45) return 90;
if (x > -45) return 0;
if (x > -135) return -90;
if (x > -225) return -180;
if (x > 315) return -270;
return -360;
} |
5fa6d93f-e522-465f-b403-a09c0ea3dc68 | 7 | public int[][] labeling(BufferedImage image){
int label = 0;
int width = image.getWidth();
int height = image.getHeight();
labeledImage = new int[height][width];
//start labeling
for(int h = 1 ; h < height-1; h++){
for(int w = 1 ; w < width-1; w++){
int pixel = im... |
cb4c2b6a-5c51-4ddd-a72e-10a125ee9345 | 7 | private void completeNickname(KeyEvent e) {
e.consume();
String text = getText();
if ( text.trim().isEmpty() )
return;
AbstractTab activeTab = InputHandler.getActiveTab();
if (activeTab instanceof ChannelTab == false)
return;
ChannelTab tab = (C... |
7ea3653c-99a2-41f4-8691-dfa0a4b9deda | 8 | @Override
public Object getValueAt(int row, int col) {
switch (col) {
case 0:
return this.arrayListSong.get(row).getTitle();
case 1:
return this.arrayListSong.get(row).getArtist();
case 2:
ret... |
2ccc55e9-a6b3-4f7c-965c-b6d22fb88c44 | 0 | public Command getCommand(String key) {
return (Command) commands.get(key);
} |
12c2447c-7b89-4b8c-ba93-8ae3b78472f8 | 9 | private void broadenRiver(Tile tile, int broad, int rivnum) {
Point[] surrPoints = Utils.getSurroundingPoints(tile.origin);
for (Point p : surrPoints) {
Tile t = MyzoGEN.getOutput().getTile(p);
if (t != null && t.riverID == -1 && t.floor == tile.floor) {
t.tile = Tiles.WATER;
t.river = true;
t.riv... |
612cc598-accf-4cc3-9e81-4603525be04e | 2 | @Override
public void run() {
while (Fenetre._state != StateFen.Level) {
// Verifie l'etat du menu toute les demi-seconde
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
} |
19d6a101-c536-42be-96fd-d227e77675c6 | 7 | final private boolean jj_3R_199() {
Token xsp;
xsp = jj_scanpos;
if (jj_scan_token(113)) {
jj_scanpos = xsp;
if (jj_scan_token(114)) {
jj_scanpos = xsp;
if (jj_scan_token(115)) {
jj_scanpos = xsp;
if (jj_scan_token(116)) {
jj_scanpos = xsp;
if (jj_scan_token(117)) {
jj_sc... |
dffe7642-444a-48a6-b977-dd6208fe15b1 | 7 | private static void writeResampledFile(OtuWrapper wrapper,
List<Integer> resampledList, boolean discrete, boolean allSameDepth,
int maxIndex, int maxDepth) throws Exception
{
File outFile =
new File(
ConfigReader.getBigDataScalingFactorsDir()
+ File.separator + "risk" +
File.separat... |
1cf3bbad-5827-4a38-b4a5-58c980cb7a1c | 4 | public BroadcastMessageParser(byte[] data){
super(data);
this.nickLength = data[510];
this.hostLength = data[511];
byte[] tempNickAsBytes = new byte[255];
byte[] tempHostAsBytes = new byte[255];
System.arraycopy(data, 0, tempNickAsBytes, 0, this.nickLength);
System.arraycopy(data, 255, tempH... |
bd18ef6e-012a-407a-be67-3f9f43bb6fe9 | 7 | public static Cons allEquivalentCollections(LogicObject self, boolean reflexiveP) {
{ Cons equivalents = Cons.consList(Cons.cons(self, Stella.NIL));
List unscannedequivalents = List.list(Cons.cons(self, Stella.NIL));
LogicObject u = null;
if (LogicObject.allSupercollections(self).memberP(self)) {... |
ae414d55-80c3-4079-8c86-7cea3dc2f8ab | 1 | public void sendAttackResult(boolean result) {
if (gui != null) {
gui.updateState(eBattleFieldMode.Displaying);
}
Message<Boolean> attackResult = new Message<>();
attackResult.setMessageType(eMessageType.attackResult);
attackResult.setDataContainer(result);
op... |
906e70ad-fe33-479d-970d-e4ec7519dd64 | 3 | * @return Returns true if the the connection between the given terminals
* is valid.
*/
public boolean isValidConnection(Object source, Object target)
{
return isValidSource(source) && isValidTarget(target)
&& (isAllowLoops() || source != target);
} |
c0f4fc1b-2516-447b-8599-03ce270911e5 | 5 | byte[] expandChunkData(byte[] input, int inputLength, byte[] buffer, PassthroughConnection ptc) {
if(buffer.length < inputDataBufferSize + outputDataBufferSize + expandedBufferSize + 320 || inputLength > inputDataBufferSize) {
return null;
}
ptc.inflate.reset();
ptc.inflate.setInput(input, 0, inputLength);... |
b9472ec0-3008-49e3-998d-0383b8f3d0be | 9 | @Override
public boolean okMessage(Environmental host, CMMsg msg)
{
if(((msg.sourceMinor()==CMMsg.TYP_QUIT)
||(msg.sourceMinor()==CMMsg.TYP_SHUTDOWN)
||((msg.targetMinor()==CMMsg.TYP_EXPIRE)&&(msg.target()==oldRoom))
||(msg.sourceMinor()==CMMsg.TYP_ROOMRESET))
&&(msg.source().location()!=null)
&&(msg.s... |
8eaf9e05-fe25-4163-b0dd-fb12786160f4 | 1 | public static void sellItemTester(String name){
if(ItemStorageInventory.create().sellItemfromStorage(name)){
System.out.println("Sell "+ name + " successfully\n");
}else
System.out.println("sell "+name+" failed\n");
} |
3915109a-0d9d-47d7-96ac-d9951f134292 | 0 | @Override
public void restoreTemporaryToCurrent(){tmp = new Color(cur.getRGB());} |
aedeb55e-4ca7-4542-a0df-0ad29c3fec7c | 0 | private void getdefaults() {
config.options().copyDefaults(true);
} |
c4790d67-3876-4a5b-a59b-a9a0f213ed43 | 7 | private static void getLocations(){
BufferedReader buffer = null;
int id = 0;
Region region = null;
try{
String sCurrentLine;
try{
buffer = new BufferedReader (new FileReader("src/Model/Locations.txt"));
}catch(FileNotFoundException exc){
exc.printStackTrace();
}
while((sCurrentLine = buf... |
5d056ac5-218d-4844-b923-16c9a06b0a35 | 7 | public HTTPResponse generateResponse( )
{
try {
final DocumentController controller =
ControllerFactory.getController(
request.getResource().substring(1)
);
switch (request.getMethod()) {
case GET:
... |
42026c44-36f0-4c68-9388-e5d5f6caf0ac | 4 | public static boolean sessionDelete(String sessionID, int versionNum, Server server) {
try {
DatagramSocket RPCSocket = new DatagramSocket();
RPCSocket.setSoTimeout(1000);
String callID = UUID.randomUUID().toString(); // A unique id for this call
String tempSend = callID + "^" + SESSIONDELETE_CODE... |
694e1f46-c32d-4a3e-8890-4e3527794bcd | 2 | private synchronized void recenterMouse() {
if (robot != null && comp.isShowing()) {
centerLocation.x = comp.getWidth() / 2;
centerLocation.y = comp.getHeight() / 2;
SwingUtilities.convertPointToScreen(centerLocation,
comp);
isRecentering = true;
... |
a45b674b-be15-447b-a59f-a5216b39ddf6 | 5 | @Override
public PaintResource get(Widget widget) {
final boolean temp = (highlight && widget.isHovered());
return new PaintResource(new GradientPaint(widget.getX(), widget.getY(), (temp) ? primary.brighter() : primary, widget.getX() + ((direction & HORIZONTAL) == HORIZONTAL ? widget.getWidth() : 0)... |
a43212cd-1e21-4dc6-a8e5-b25b66e89f06 | 2 | public int maxProfit(int[] prices) {
int max = 0;
for(int i =0;i< prices.length-1;i++){
if(prices[i+1]> prices[i])
max += prices[i+1]- prices[i];
}
return max;
} |
21d7512d-117f-42c3-83cd-4398aa3daef3 | 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... |
9fd8bacf-75f4-42f2-aaf1-fde654dc10e1 | 6 | private void generarOperacionAleatoria(int a, int b, int c)
{
//En caso de que sea una division y el divisor sea 0, se le asigna un nuevo valor al divisor sin considerar el cero.
if (b == 0 && c == 4) {
b = Aleatorio(1, 10);
}
switch (c)
{
case 1: ... |
aa044fe7-5bb9-4312-92de-94bfa77b5abb | 9 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
// Apparently this is bad style, but we need interfaces and classes with
// the same name and package to be equal
if (getClass().getSuperclass() != obj.getClass().getSuperclass())
return false;... |
5b42492d-3756-49c0-ac7d-0741c447336b | 4 | public static boolean isStringPalindrome(String str){
List<Character> chars = new LinkedList<>();
for (Character item : str.toCharArray()){
chars.add(item);
}
ListIterator<Character> str1 = chars.listIterator();
ListIterator<Character> str2 = chars.listIterator(chars... |
48a6523d-4ee0-4873-9513-542e946be997 | 9 | int editDistance(String s1, String s2){
if(s1==null && s2==null)
return 0;
else if(s1==null)
return s2.length();
else if(s2==null)
return s1.length();
else {
int l1 = s1.length();
int l2 = s2.length();
int[][] dp = n... |
483ac848-3395-4ff1-9d5e-d6d6b2d878a5 | 6 | public static final ArrayList<SimpleEntry<String, String>> readFile(String filename) {
ArrayList<SimpleEntry<String, String>> stringList = new ArrayList<SimpleEntry<String, String>>();
try {
FileInputStream input = new FileInputStream(filename);
BufferedReader reader = new BufferedReader(new InputStreamReader... |
349983c2-1499-4290-968c-ff108e6284ee | 6 | private boolean nonZero(Object obj){
if(obj==null)
return false;
if(obj instanceof Boolean){
return ((Boolean)obj).booleanValue();
}
if(obj instanceof Float || obj instanceof Double){
return ((Number)obj).doubleValue()!=0.0;
}
if(obj instanceof Number){
return ((Number)obj).longValue()!=0;
}
... |
b9fe5d85-2bd0-43d7-83d0-07193701266b | 7 | protected static Ptg calcSmall( Ptg[] operands ) throws CalculationException
{
if( operands.length != 2 )
{
return new PtgErr( PtgErr.ERROR_VALUE );
}
Ptg rng = operands[0];
Ptg[] array = PtgCalculator.getAllComponents( rng );
if( array.length == 0 )
{
return new PtgErr( PtgErr.ERROR_NUM );
}
i... |
e00538f3-b64f-4422-9bc0-bc58a6d09546 | 6 | public void update(float dt){
if(moving){
if(path!=null)
goalPosition = path.getCurrent();
if(goalPosition!=null) {
//offset Tile image according to speed?
tile.setOffsetX(tile.getOffsetX() + dt);
//finished moving?
if(true){
if(path!=null){
path.stepIndex();
if(pat... |
fb99bc40-1a5c-41ea-962b-df5d23768529 | 3 | public int Expect(String Data, int NumBytes )
{
byte target = 0;
int cnt = 0;
try
{
while ((NumBytes--) != 0)
{
target = file.readByte();
if (target != Data.charAt(cnt++)) return DDC_FILE_ERROR;
}
} catch (IOException ioe)
{
return DDC_FILE_ERRO... |
1e02f21c-d72a-457d-902f-9f1a4319eae1 | 9 | public static ArrayList<Integer> slidingMaximumDqueue(final List<Integer> a, int b) {
ArrayList<Integer> result = new ArrayList<Integer>();
Deque<Integer> deque = new ArrayDeque<>();
for (int i = 0; i < b; i++) {
while (!deque.isEmpty() && a.get(deque.getLast()) <= a.get(i)) {
... |
005df314-8118-4fdc-978d-b09f73a2af66 | 5 | private void RemovePlayer(Player player) {
if (_fightingPlayers.contains(player)) {
_fightingPlayers.remove(player);
String message = String.format("Tribute '%s' has been killed",
player.getName());
ChatManager.sendMessageToServer("GameMaker", message);
}
if (_playerSpawns.containsValue(player)) {
... |
e8407197-909f-4388-bff8-5dead8336d2e | 7 | public void create(User user) throws RollbackFailureException, Exception {
if (user.getArticleList() == null) {
user.setArticleList(new ArrayList<Article>());
}
EntityManager em = null;
try {
utx.begin();
em = getEntityManager();
List<Artic... |
8014b73d-6a25-49ae-a9f9-ebe66738c364 | 9 | public void saveIntoXMLFile( String filename ) {
try {
// set up xml doc factory
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder db = factory.newDocumentBuilder();
Document xmlDoc = db.newDocument();
// set up xml builder
TransformerFactory tf = TransformerFac... |
5bfc8be0-2a10-4e57-9214-e4f845da6427 | 5 | private void genPositionBloc( int nbPositionBloc )
{
PositionBloc position = null;
PositionBloc positionNouvelle = null;
int numeroVoie = 0;
// création manuelle du premier bloc de la voie.
if( this.sens == 1 )
{
position =... |
8cfa778d-80d3-412d-a49d-d94129833643 | 1 | public void kertausmaatti(){
File kertaustiedosto = kertauspaneeli.hankiTiedosto("Valitse tiedosto");
if (kertaustiedosto != null){
kertausmaatti.setTiedosto(kertaustiedosto);
kertausmaatti.haeTunnisteet();
kertauspaneeli.luoTunnisteidenValinta();
CardLayo... |
8e1748ef-7416-4881-9255-4eeea41de830 | 7 | public void printToFile(String filePath) {
try {
StringBuilder sbOutput = new StringBuilder();
// Output each member of settings.
for (Field field : this.getClass().getDeclaredFields()) {
String typestr = field.getType().toString().toLowerCase();
if (typestr.endsWith("string") || typestr.endsWith("in... |
e7c9aee4-6c6c-4930-b611-c7c0026f66c7 | 1 | public void writeCode(Code code) throws IOException {
// call putBit() on all bits, from left to right
for (int i = code.length() - 1; i >= 0; i--) {
putBit(code.getBit(i));
}
} |
947b4da6-0a3c-4e6b-a6a6-b9bae77f7d79 | 9 | public Pair<Symbol, SymbolString> getAmbiguousCore() {
AmbNode amb = getMinimalParseTree();
if (amb == null) {
String s = "No ambiguity node found for " + top.getRootSymbol() + " : " + top.yield().prettyPrint();
System.out.println(s);
//throw new RuntimeException(s);
return new Pair<Symbol, SymbolStr... |
0bf2a17a-93c8-4469-956b-2d76c93088d4 | 6 | public void followPlayer(Rachel r){
if(seePlayer(r)){
follow++;
}
if(follow > 0){
if(r.getY() > getY()){
setDown(true);
} else {
setDown(false);
}
if(r.getY() < getY()){
setUp(true);
} else {
setUp(false);
}
if(r.getX() < getX()){
setLeft(true);
} else {
se... |
a46e8402-e363-4ba5-afa8-6c0d0520c7cb | 8 | public void maintainDealer() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, InterruptedException{
while(true){
Thread.sleep(1);//So that commands don't happen at the same exact time.
if(!callsToDealer.isEmpty()){
final ArrayList<... |
f728813e-a699-4422-8cde-88e70345aecc | 0 | public void execute() {
this.from.removePiece(this.piece);
this.to.addPiece(this.piece);
this.piece.increaseMoveCount();
} |
ae52a999-f037-4d2d-9963-b5fd007062cd | 3 | public static String removeAccelerator(String text)
{
String modifiedText = text;
// Search for ~
int location = text.lastIndexOf(CONTROL_2);
// If not found then search for hex EE
if (location < 0)
{
location = text.lastIndexOf(CONTROL_1);
}
// If not found then search for '&'
if (location < 0... |
97e2f69c-5887-4de5-bc08-325707992628 | 3 | public static boolean readBoolean()
{
String token = getNextToken();
boolean bool;
try
{
if (token.toLowerCase().equals("true"))
bool = true;
else if (token.toLowerCase().equals("false"))
bool = false;
else
{
error ("... |
588cd822-3f59-486c-a75b-be80d04f2f89 | 7 | public static void reset_branch(String num, String filepath, String downloadpath, Scanner scanner){
String line="", result = "";
int item=0;
System.out.println("Please choose the reset button's status that you want to test: 1=press, 2=release, 0=return:");
System.out.println("If you choose to test the pressed s... |
a50ebe6a-72ac-4a96-952c-335de52cf14c | 0 | @GET
@Path("events/{id}/cars")
@Produces({MediaType.APPLICATION_JSON })
public List<Car> getEventCars(@PathParam("id")int idEvent){
System.out.println("Return the cars list of the event selected by the id");
return JpaTest.eventService.getCars(idEvent);
} |
375c1328-fe69-403c-88ae-48d03745c0a1 | 1 | static final int Mix3To1(final int c1, final int c2) {
//return (c1*3+c2) >> 2;
if (c1 == c2) {
return c1;
}
return ((((c1 & Mask2) * 3 + (c2 & Mask2)) >> 2) & Mask2) |
((((c1 & Mask13) * 3 + (c2 & Mask13)) >> 2) & Mask13) |
((((c1 & Mask4) >> 2) * 3 + ((c2 & Mask4) >> 2)) & Mask4);
} |
b09a4192-6883-450c-a7d3-984f8d6f7313 | 0 | public String getAcademicLevel() {
return AcademicLevel;
} |
37c5113e-cf83-42a6-aa25-dfd751fe5fbf | 9 | @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] split) {
boolean r = false;
if (sender instanceof Player) {
Player player = (Player) sender;
if (instance.pex.has(player, "bitreport.report")) {
if (split.length > 0) {
String data = "";
for (in... |
914403e9-2fb2-43ce-87a0-bb42a70b5467 | 7 | private boolean isFalseCharacter(char c) {
if (c == '(' || c == ')' || c == '1' || c == '0' || c == ' ')
return false;
for (int i = 0; i < operator.length; i++) {
if (c == operator[i])
return false;
}
return true;
} |
2662ac5c-055c-445f-9960-e3fb15f6b21f | 7 | public static boolean ProcessorUpdateList()
{
File list = FileManager.modList;
installedMods = FileManager.installedMods;
installedCoreMods = FileManager.installedCoreMods;
if (list != null && list.exists())
{
try
{
List<String> mods =... |
3c6a21de-28a9-4b2d-b4d4-c9b2d1d6abb4 | 3 | private void initComponents() {
selectSectionLbl = new JLabel();
selectSectionScrollPanel = new JScrollPane();
selectSectionJTable = new JTable();
selectDirectionLbl = new JLabel();
motherLangTransRadioBtn = new JRadioButton();
transMotherLangRadioButton = new JRadioButt... |
242072a6-5509-40ac-9554-7280e2ea5fda | 6 | public boolean win(Value sign) {
Boolean win = false;
if (sign != Value.empty) {
for (int pointer = 0; pointer < EngineField.sizeField; pointer++) {
if (checkColumn(pointer, sign)) win = checkColumn(pointer, sign);
if (checkLine(pointer, sign)) win = checkLine... |
e63eb24d-bf3a-436e-a9ce-cf2ab2096297 | 2 | protected int parseInt(String input) {
int i;
if (input == null) {
i = FAILURE;
} else {
try {
i = Integer.parseInt(input);
} catch (NumberFormatException e) {
i = FAILURE;
}
}
return i;
} |
eb659f19-5d05-40c0-b272-8ee9b19191d8 | 1 | public static String quote(String str) {
return (str != null ? "'" + str + "'" : null);
} |
b888158f-776b-40c7-8bc7-5da7cc191a8a | 7 | public void start(final Stage primaryStage) {
try {
Context.get().setSingleton(Stage.class, primaryStage);
Context.get().setSingleton(Application.class, this);
this.application = loadApplicationLoader();
Context.get().setSingleton(ApplicationLoader.class,
this.application);
this.application.init(p... |
a1fb5eed-20f9-48d6-a02a-5c2b952b2cbb | 6 | public static void main(String[] args){
HashMap<String, Command> cmds = new HashMap<String, Command>();
cmds.put("ADD", new Add());
cmds.put("DEF", new Define());
cmds.put("DIV", new Div());
cmds.put("MUL", new Mul());
cmds.put("POP", new Pop());
cmds.put("PRN", n... |
c9e9ea13-53b0-41d7-a479-df104ed0339e | 6 | private void initialise() throws IOException {
// Reads the state of the ContactManager from a CSV File.
BufferedReader CSVFile = new BufferedReader(new FileReader(fileName));
String dataRow = CSVFile.readLine();
// System.out.println(dataRow);
// Reads each line... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.