text stringlengths 14 410k | label int32 0 9 |
|---|---|
private void checkPaddles(Paddle left, Paddle right) {
int edgeOfPaddle = left.getCoordinates()[0] + left.getWidth();
// if ball is to the left of left paddle in relation to X-position...
if(coordinates[0] + deltaX <= edgeOfPaddle && coordinates[0] + 2*radius + deltaX >= left.getCoordinates()[0]) {
int left... | 8 |
@Override
public Class<?> getColumnClass(int col) {
switch (col) {
case 0:
case 1:
case 2:
case 3: return String.class;
default:
return null;
}
} | 5 |
public void passEvent(Event event) {
for(Processor processor : this) {
processor.recieveEvent(event);
}
} | 1 |
public String processInputMessage(String message) {
/**
* Firstly: check to see if the message was a command:
*/
if(message.charAt(0) == '/') {
System.out.println("Client has issued a command!");
/*
* Handle any arguments provided, splitting into strings
* at spaces - all added into an array.... | 5 |
@Override
public String toString() {
String path = "";
String separator = System.getProperty("file.separator");
if(System.getProperty("os.name").contains("Windows")) {
if(isRoot) {
path += pathelements.get(0).toString().toUpperCase() + ":" + separator;
pathelements.remove(0);
}
}
else {
if(i... | 5 |
@Override
public synchronized void onApplicationEvent(ContextRefreshedEvent event) {
try {
if (persistenceService.count(Beer.class) == 0) {
CSVReader reader = new CSVReader(new FileReader(resource.getFile()));
reader.readNext(); //skip first line with headers
... | 5 |
public boolean validatePosition(EnumLine line, EnumColumn column,
boolean vertical, EnumElement vessel) {
final int initLinePosition = line.getPosition();
final int initColumnPosition = column.getPosition();
for (int i = 1; i < (vessel.getLength() + 1); i++) {
if (vertical) {
line = EnumLine.getEnumLi... | 4 |
private void separateCommonEdges(ArrayList shapes){
float offset = getMinimumOfCellDimension() / 5;
ArrayList<ShapeEdge> edges = new ArrayList<ShapeEdge>();
//get all adges
Iterator it = shapes.iterator();
while (it.hasNext()) {
DiagramShape shape = (DiagramShape) it.next();
edges.addAll(shape.getEdg... | 7 |
private static Object fetchPrimitiveArrayValue(Object array, int index, Class<?> componentType) {
if (long.class.equals(componentType)) {
return ((long[]) array)[index];
}
if (int.class.equals(componentType)) {
return ((int[]) array)[index];
}
if (boolean.class.equals(componentType)) {
return ((boole... | 9 |
@Override
public void valueUpdated(Setting s, Value v) {
String setting = s.getName();
if (setting.equals(Text)) {
if (!loopFlag_) {
loopFlag_ = true;
if (textField_ != null)
textField_.setText(v.getString());
} else
loopFlag_ = false;
} else if (setting.equals(Trigger)) {
try {
Tex... | 8 |
public void move(){
if(getDirection() == Moveable.RIGHT)
setX(getX() + speed);
else if(getDirection() == Moveable.LEFT)
setX(getX() - speed);
else if(getDirection() == Moveable.UP)
setY(getY() - speed);
else if(getDirection() == Moveable.DOWN)
setY(getY() + speed);
if(getX() <= 0)
setDirecti... | 8 |
public static void setPropertyDefaultAsString(PropertyContainer container, String key, String default_value) {
if (container != null) {
container.setPropertyDefault(key, default_value);
} else {
throw new IllegalArgumentException("Provided PropertyContainer was null.");
}
} | 1 |
public String getName()
{
return name;
} | 0 |
public static void main(String[] args)
{
ScriptEngineManager factory = new ScriptEngineManager();
ScriptEngine engine = factory.getEngineByName("Javascript");
try
{
engine.eval("");
}
catch(ScriptException ex)
{
ex.printStackTrace();
... | 1 |
@Override
public void execute() {
Forum forum;
try {
forum = ForumParser.parse(controller.forumDisplay(REPORTED_POSTS_FORUM_ID));
} catch (IOException e) {
controller.getModel().setReportSearchTask(null);
logger.warn("Failed to parse forum.", e);
stop();
return;
}
for (ForumThread thread : fo... | 4 |
public Object nextEntity(char ampersand) throws JSONException {
StringBuffer sb = new StringBuffer();
for (;;) {
char c = next();
if (Character.isLetterOrDigit(c) || c == '#') {
sb.append(Character.toLowerCase(c));
} else if (c == ';') {
... | 5 |
public static ArrayList<ArrayList<Integer>> obtenerRestricciones(String operacion) {
ArrayList<ArrayList<Integer>> restricciones = new ArrayList<>();
ArrayList<Integer> posiciones;
boolean existeRestriccion = false, bandera = false;
for (int i = 0; i < operacion.length(); i++) {
... | 8 |
public void previewFile (String filePath) {
Ctabinterface singleSource = null;
String fileName = null, callableFunction = null;
if (filePath == null) {
synchronized (tabbedPaneLocker) {
singleSource = (Ctabinterface) tabbedPane.getSelectedComponent();
}
... | 9 |
public void actionPerformed(ActionEvent ev)
{
try
{
AreaConhecimento objt = classeView();
if (obj == null)
{
long x = new AreaConhecimentoDAO().inserir(objt);
objt.setId(x);
JOptionPane.showMessageDialog(null,
"Os dados foram inseridos com sucesso", "Sucesso", JOptionPane.INFORMATION_MES... | 3 |
public static Parametros getInstance(){
if (instance==null) {
instance = new Parametros();
}
return instance;
} | 1 |
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerMove(PlayerMoveEvent event) {
if (event.isCancelled()) return;
if (!ChunkyManager.getChunkyWorld(event.getTo().getWorld().getName()).isEnabled()) return;
ChunkyChunk toChunk = ChunkyManager.getChunkyChunk(event.getTo());
... | 3 |
public void run(long millisBetweenPhases) {
long time, sleepTime;
this.stop = false;
while(!stop && !this.finalStateAchieved()) {
time = - System.currentTimeMillis();
//Execute the handlers before running the phase
for(RunEnviron... | 8 |
private int find(ArrayList<Integer> current, HashMap<Integer, Boolean> diagonal1,
HashMap<Integer, Boolean> diagonal2, int n) {
int result = 0;
if (current.size() == n) {
return 1;
} else {
//find available column
int row = current.size();... | 6 |
@Override
public void getDatas() throws IOException, SAXException, ParserConfigurationException {
try {
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
InputStream input = new FileInputStream("src/main/resources/xsd-xml/Delivery.xml");
XMLStreamReader stream... | 8 |
public int editDistance(String s1, String s2)
{
int m=s1.length();
int n=s2.length();
int[][]d=new int[m+1][n+1];
for(int i=0;i<=m;i++){
d[i][0]=i;
}
for(int j=0;j<=n;j++){
d[0][j]=j;
}
for(int j=1;j<=n;j++){
for(int i=1;i<=m;i++){
... | 5 |
private static boolean hasNodeStyleClass(Node node, String className) {
String c = DOM.getElementAttribute(node.<com.google.gwt.user.client.Element>cast(), "class");
if (c != null && c.length() > 0) {
String[] classes = c.split(" ");
for (int i = 0; i < classes.length; i++) {
... | 4 |
public String getTag(String compSHDataStr) {
final String tagBase64Str;
final byte[] tagBytes;
final byte[] cipherTextBytes;
final String HMACType = "HmacSHA256";
// TODO clean correct/cleanup try/catch
try {
SecretKeySpec SKSHMACKey = new SecretKeySpec(HMACK... | 2 |
public void setSetpointRelative(double setpoint){
if(m_pidMode == DRIVE_TO_DISTANCE_MODE){
super.setSetpoint(ultrasonic.getRangeInches());
super.setSetpointRelative(setpoint);
}else if(m_pidMode == DRIVE_TO_ANGLE_MODE || m_pidMode == ROTATE_TO_ANGLE_MODE){
super.setSe... | 3 |
public void compExecTime() {
double newExeTime;
double newCost;
dEval = 0;
dTime = 0;
dCost = 0;
for (int i = 0; i < iClass; i++) {
newExeTime = 0;
// System.out.print("Cost[" + i + "]");
for (int j = 0; j < iSite; j++) {
if (dmAlloc[i][j] != -1) {
if (dmAlloc[i][j] < 1) {
newExeTime... | 8 |
@Test
public void tiedostonLukeminenToimiiFailillaSyotteella(){
kirjoitaFailinmuotoinenSyote();
tiedot.LueTiedotTiedostosta();
String mappiinTallennetutTiedot = "";
HashMap<String, Integer> kartta = tiedot.getOpiskelut();
for (String avain: kartta.keySet()){
... | 1 |
public List<String> lerArquivo(String pArquivo)throws Exception
{
File f = new File(pArquivo);
List<String> retorno = new ArrayList<String>();
try
{
BufferedReader in = new BufferedReader(new FileReader(f));
String line;
... | 4 |
@Test
public void compareHands_TwoFullHousesWithSameTripsSamePairs_HandsAreEqual() {
Hand p1 = Hand.FullHouse(Rank.Four, Rank.Nine);
Hand p2 = Hand.FullHouse(Rank.Four, Rank.Nine);
assertTrue(p1.compareTo(p2) == 0);
} | 0 |
@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 Endereco)) {
return false;
}
Endereco other = (Endereco) object;
if ((this.id == null && other.id != null) || (... | 5 |
public void sample(int position) {
// Ignore counts for zero or one-length chromosomes
if (length <= 1) {
// Gpr.debug("Warning: Chromosome '" + chrName + "' has length " + chrLength);
return;
}
int i = position / factor;
if ((i >= 0) && (i < count.length)) {
count[i]++;
total++;
} else Gpr.deb... | 3 |
private void loadID3v2(InputStream in)
{
int size = -1;
try
{
// Read ID3v2 header (10 bytes).
in.mark(10);
size = readID3v2Header(in);
header_pos = size;
}
catch (IOException e)
{}
finally
{
try
{
// Unread ID3v2 header (10 bytes).
in.reset();
}
catch (IOExcepti... | 4 |
private void printMWList(){
CSVWriter csvW = new CSVWriter();
Set<String> callees = midwarereferences.keySet();
for(String callee : callees){
if(callee.equals("DEFAULT XFB-routine")){
ArrayList<String> callers = midwarereferences.get(callee);
if(callers!=null){
for(String caller : callers){
... | 7 |
private Direction decideMove(CurrentCell cell) {
log(String.format("(%d, %d) [E:%s, W:%s, N:%s, S:%s]", cell.getX(), cell.getY(), cell.getEast(), cell.getWest(), cell.getNorth(), cell.getSouth()));
RouteState eRouteState = RouteState.valueOf(cell.getEast());
RouteState wRouteState = Rou... | 7 |
public static String unescape(String string) {
int length = string.length();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < length; ++i) {
char c = string.charAt(i);
if (c == '+') {
c = ' ';
} else if (c == '%' && i + 2 < length) {
... | 6 |
private static void update() {
if (enabled) {
panel.removeAll();
comps.clear();
for (String s : strings.keySet()) {
comps.add(new JLabel(s + ": " + strings.get(s)));
}
for (String s : integers.keySet()) {
comps.add(new ... | 7 |
public static boolean channelExists( String name ) {
for ( Channel c : channels ) {
if ( c.getName().equals( name ) ) {
return true;
}
}
return false;
} | 2 |
private String showParamHelp(ParamCons cons) {
StringBuilder rtn = new StringBuilder();
rtn.append(cons.name);
rtn.append(' ');
rtn.append('{');
switch(cons.type) {
case ParamCons.INTEGER:
rtn.append("Integer");
break;
case ParamCons.STRING:
rtn.append("String");
break;
}
rtn.append("} ... | 3 |
short deinitialize()
{
if (!is_init)
{
MsgDumperCmnDef.WriteErrorSyslog(__FILE__(), __LINE__(), "Library has been initialized");
return MsgDumperCmnDef.MSG_DUMPER_FAILURE_INCORRECT_OPERATION;
}
short ret = MsgDumperCmnDef.MSG_DUMPER_SUCCESS;
// Notify to DeInitialize the worker thread
for (int i = 0 ;... | 7 |
public RPMInfo resolve(RPMRequest req) throws Exception {
loadRepoInfo();
List<RPMInfo> rpms=rpmInfo.get(req.name);
if(rpms!=null&&!rpms.isEmpty()) {
RPMInfo resolved=null;
for(RPMInfo info:rpms) {
if(req.arch==null||info.arch.equals(req.arch)) {
... | 9 |
public void setVerbose(boolean verbose) {
this.verbose = verbose;
} | 0 |
public String getSaveFileFormatNameForExtension(String extension) {
String lowerCaseExtension = extension.toLowerCase();
for (int i = 0, limit = savers.size(); i < limit; i++) {
SaveFileFormat format = (SaveFileFormat) savers.get(i);
if (format.extensionExists(lowerCaseExtension)) {
return (String) saverN... | 2 |
public boolean getBoolean(String key) throws JSONException {
Object object = this.get(key);
if (object.equals(Boolean.FALSE) ||
(object instanceof String &&
((String)object).equalsIgnoreCase("false"))) {
return false;
} else if (object.equals(Boolean.T... | 6 |
public void actionPerformed( ActionEvent e )
{
int hash = e.getActionCommand().hashCode() ;
// System.out.println("Action from " +e.getID() +" " +e.getActionCommand()) ;
// enter comes only, if the data of the sender has been changed
if ( hash == "enter".hashCode() )
{
adoptData( e.getID()... | 5 |
public static void drawPortal(
QTRenderNode n, float nodeSize, float ncx, float ncy, float distance,
Display disp, float scx, float scy, float scale
) throws ResourceNotFound {
// clip to actual region on screen being drawn at
float dscale = scale/distance; // Scale, taking distance into account
float ... | 8 |
static protected void FillBuff() throws java.io.IOException
{
if (maxNextCharInd == available)
{
if (available == bufsize)
{
if (tokenBegin > 2048)
{
bufpos = maxNextCharInd = 0;
available = tokenBegin;
}
else if (tokenBegin < 0)
bufpos... | 9 |
@Override
public BeerResponse addBeer(BeerRequest beerRequest) {
BeerReadOnly beerReadOnly = barService.addBeer(beerRequest);
return new BeerResponse(beerReadOnly);
} | 0 |
public static void main(String[] args) throws IOException
{
decodeCombined decoder = new decodeCombined();
BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(args[0])));
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(args[1])));
String recie... | 2 |
public GUI() {
setTitle("Snake Timo");
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
setFocusable(true);
setBounds(new Rectangle(595, 624));
setExtendedState(Frame.MAXIMIZED_BOTH);
game = new Game(getBounds().getSize());
spie... | 0 |
public void run() {
//start collectors
for (Konto collector : kontosbox) {
if (collector.getTyp().startsWith("SMTPOutgoingMailServer")) continue;
new MailCollectorThread(emailsbox, collector, sleeptime).start();
}
//start Keeperthread
//accept POP3 incom... | 8 |
@Override
public boolean lisaaTyopaiva(Tyopaiva tyopaiva) {
boolean loytyikoTyopaiva = false;
for (Tyopaiva tyopaiva1 : tyopaivat) {
if (tyopaiva.equals(tyopaiva1)) {
loytyikoTyopaiva = true;
}
}
if (!loytyikoTyopaiva) {
tyopaivat.... | 3 |
@Override
public void doSteps(){
if(lastImpr >= MIN_PROG){
stuck = true;
int addIndex;
double etime = System.currentTimeMillis() + repTime;
int i=0;
while(( (nrOfSteps > 0 && i < nrOfSteps)
|| (repTime > 0 && System.currentT... | 9 |
private void updateBuddies(int characterId, int channel, int[] buddies, boolean offline) {
final PlayerStorage playerStorage = server.getPlayerStorage();
for (int buddy : buddies) {
final MapleCharacter chr = playerStorage.getCharacterById(buddy);
if (chr != null) {
final BuddylistEntry ble = chr.getBuddy... | 5 |
public void essayerSortirPrison(Dices dices) throws NoMoreMoneyException
{
//Si le nombre d'essai est dépassé
// TODO : incohérence dans les notifications
if(cptPrison == 3)
{
sortirPrison();
payer(50);
setChanged();
}
else
{
//Si on obtient un double
if(dices.isDouble()) {
sor... | 2 |
public void setIsSelected(Boolean isSelected) {
this.isSelected = isSelected;
} | 0 |
public void setPassRate(Integer passRate) {
this.passRate = passRate;
} | 0 |
public int[] intersection(int[] nums1, int[] nums2) {
if (nums1 == null || nums1.length == 0 || nums2 == null || nums2.length == 0) {
return new int[0];
}
Arrays.sort(nums1);
Arrays.sort(nums2);
int i = 0, j = 0;
List<Integer> list = new ArrayList<Integer>();
while (i < nums1.length && j < num... | 9 |
public static int getNextNullTerminator(byte[] buffer, int startingFrom, Charset charset)
{
int index=0;
if (charset.equals(CHARSET_ISO_8859_1))
{
for(index=startingFrom; index<buffer.length && buffer[index] != 0; ++index);
}
else if (charset.equals(CHARSET_UTF_16))
{
... | 7 |
private static void buildFilesForRecoveryTemplates(
String indexFilename,
String templatesFilename,
char[] newTerminalIndex,
char[] newNonTerminalIndex,
String[] newName,
char[] newLhs,
String[] tokens) {
int[] newReverse = computeReverseTable(newTerminalIndex, newNonTerminalIndex, newName);
char[] newRecove... | 7 |
public void updateSizesAndHeights() {
double assignedHeight = 0;
int unassigned = 0;
double hr = 0.0;
// for each btc in the tp
for (Iterator<BaseTableContainer> it = rowList.iterator(); it.hasNext();) {
BaseTableContainer comp = it.next();
hr = comp.getHe... | 8 |
public ServiceDescriptor findServiceByName(String name) {
// Don't allow looking up nested types. This will make optimization
// easier later.
if (name.indexOf('.') != -1) {
return null;
}
if (getPackage().length() > 0) {
name = getPackage() + '.' + name;
}
fin... | 5 |
@Override
public void onSetFileAttributes(String path, int fileAttributes, DokanFileInfo fileInfo)
throws DokanOperationException {
try {
path = mapWinToUnixPath(path);
fileSystem.setWindowsAttributes(path, new WindowsAttributes(fileAttributes));
} catch (PathNotFoundException e) {
throw new DokanOpera... | 4 |
private void remove() {
try {
Agent agent;
int i;
int option;
UI.printHeader();
System.out.println(agents.size() + " agentes activos:");
System.out.println("");
for (i = 0; i < agents.size(); i++) {
agent = agents.get(i);
System.out.println((i + 1) + ") Agente: "
+ agent.getType()... | 3 |
private void closeChannels() {
try {
if (serverSocketChannel != null && serverSocketChannel.isOpen())
serverSocketChannel.close();
if (datagramChannel != null && datagramChannel.isOpen())
datagramChannel.close();
if (stdin != null && stdin.isOpen())
stdin.close();
} catch (IOException e) {
e... | 7 |
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
UnixTimeInterval other = (UnixTimeInterval) obj;
if (end == null) {
if (other.end != null)
return false;
} else if (!end.equals(other.en... | 9 |
@Override
public void run() {
if (ctx == null) {
return;
}
if (ctx.getFile() == null) {
return;
}
File root = ctx.getFile();
if (!root.isDirectory()) {
logger.debug("root " + root.getAbsolutePath() + " is not directory!");
return;
}
if (!root.exists()) {
... | 9 |
public void actionPerformed(ActionEvent e) {
String ac = e.getActionCommand();
if (ac.equals("gotoStart")) {
pauseButton.doClick();
gotoStart();
update();
} else if (ac.equals("stepBack")) {
pauseButton.doClick();
stepBack();
update();
} else if (ac.equals("playBack")... | 8 |
private void emitCode() {
LinkedList worklist = new LinkedList();
// Create an instantiation of the "root" subroutine, which is just the
// main routine
worklist.add(new Instantiation(null, mainSubroutine));
// Emit instantiations of each subroutine we encounter, including the
... | 1 |
public OfflinePlayer[] getGhosts() {
validateState();
Set<OfflinePlayer> players = new HashSet<OfflinePlayer>(ghostTeam.getPlayers());
// Remove all non-ghost players
for (Iterator<OfflinePlayer> it = players.iterator(); it.hasNext(); ) {
if (!ghosts.contains(it.next().... | 2 |
public static void main(String args[])
{
// remember to have this print your own name instead of I. Forgot
System.out.printf("CS261 - Assignment 2 - Kevin Bui%n%n");
// get command line arguments
if (args.length != 5) {
System.out.println("requires 5 arguments: nGames,... | 2 |
public void setValue(int current) {
int newCurrent = current < 0 ? 0 : current > max ? max : current;
if(newCurrent != this.current) {
this.current = newCurrent;
updateBarSize();
}
} | 3 |
public void setPalette(int[] rgb)
{
if (rgb.length < 1 * 3 || rgb.length > 256 * 3)
{
throw new IllegalArgumentException("PNGEncodeParam0");
}
if ((rgb.length % 3) != 0)
{
throw new IllegalArgumentException("PNGEncodeParam1");
}
palette = (rgb.clone());
paletteSet = true;
} | 3 |
public void refreshPanel() {
if (Sessie.getIngelogdeGebruiker().heeftPermissie(
PermissieHelper.permissies.get("INZIENALLESTUDENTEN"))) {
comboBox.removeAllItems();
comboBox.addItem("Selecteer een leerling...");
for (User student : Dao.getInstance().getStudenten()) {
comboBox.addItem(student);
}
... | 6 |
public void move(int xa, int ya)
{
//Directions:
// 0
// 3 Player 1
// 2
if (xa > 0)
{
dir = 1;
}
if (xa < 0)
{
dir = 3;
}
if (ya > 0)
{
dir = 2;
}
if (ya < 0)
{
dir = 0;
}
if (!collision())
{
x += xa;
y += ya;
}
} | 5 |
public void testBigKey250() throws TimeoutException, MemcachedException {
String readObject = null;
String key = null;
StringBuilder keyPrefix = new StringBuilder();
for(int i=0;i<249;i++) {
keyPrefix.append("k");
}
//1 - String
key = keyPrefix.toString()+"1";
c.set(key, 3600, "World");
readO... | 5 |
public void changeQuestLevel(int level){
//to account for starting at level 0
level += 1;
for(Reward reward : this.rewards){
reward.scaleMoneyReward(level);
}
for(Objective objective : this.objectives){
objective.scaleToLevel(level);
}
} | 2 |
@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
if(!name.startsWith("javablock.plugin")){
}
ZipEntry entry = this.file.getEntry(name.replace('.', '/') + ".class");
if (entry == null) {
return global.Classes.loadClass(name);... | 6 |
public synchronized boolean equals(Object obj) {
if (!(obj instanceof PingResult)) return false;
PingResult other = (PingResult) obj;
if (obj == null) return false;
if (this == obj) return true;
if (__equalsCalc != null) {
return (__equalsCalc == obj);
}
... | 8 |
public static void main (String aa[]){
String hostname = "10.200.252.104";
String username = "loadruser";
String password = "PerfTest4QA";
Connection conn = new Connection(hostname);
try {
conn.connect();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
... | 7 |
private void loadAttributes(boolean createIfNotExists) {
if (this.attributes == null) {
NbtTagCompound nbt = NbtFactory.readFromItemStack(this.stack);
this.attributes = nbt.getList("AttributeModifiers");
if (createIfNotExists && this.attributes == null) {
Nbt... | 3 |
public Integer length() {
int length = this.s.length() + 2;
if (this.encrypt) {
length += 2;
}
if (this.conflict > 0) {
length += 2;
for (final String c : this.conflictFiles) {
length += 6 + c.length();
}
}
return length;
} | 3 |
private void readZoomLevelHeader(long fileOffset, int zoomLevel, boolean isLowToHigh) {
LittleEndianInputStream lbdis = null;
DataInputStream bdis = null;
byte[] buffer = new byte[ZOOM_LEVEL_HEADER_SIZE];
try {
// Read zoom header into a buffer
fis.seek(file... | 3 |
public void execute() {
Process pro;
try {
// This three lines gives you time to kill some process so that you
// can simulate node failure and see if it recovers correctly
/*
System.out.println("[Reducer] Force to sleep");
Thread.sleep(10000);
System.out.println("[Reducer] wake up");
... | 6 |
public static Path writeMatrix(double[][] matrix, Path path,
HamaConfiguration conf) {
SequenceFile.Writer writer = null;
try {
FileSystem fs = FileSystem.get(conf);
writer = new SequenceFile.Writer(fs, conf, path, IntWritable.class,
VectorWritable.class);
for (int i = 0; i < matrix.length; i++) {
... | 4 |
private void processBuffer()// throws EOFException
{
if(bufferLength < HEADER_SIZE)
return;
justConnected = false;
Boolean isPacketReceived = bytesNeeded <= bufferLength;
if (!isPacketReceived)
{
//log.debug("packet is not received yet " + bufferLength+", " + bytesNeeded);
return;
}
inputBuf... | 4 |
protected static Ptg calcMinA( Ptg[] operands )
{
Ptg[] alloperands = PtgCalculator.getAllComponents( operands );
if( alloperands.length == 0 )
{
return new PtgNumber( 0 );
}
double min = Double.MAX_VALUE;
for( Ptg alloperand : alloperands )
{
Object o = alloperand.getValue();
try
{
doubl... | 6 |
@Override
public boolean isDiagonalObstacle(Element elementPassingThrough, Element otherDiagonalElement) {
if (otherDiagonalElement instanceof LightTrailPart)
return ((LightTrailPart) otherDiagonalElement).isDiagonalObstacle(elementPassingThrough, this);
return false;
} | 1 |
private static void svm_group_classes(svm_problem prob, int[] nr_class_ret, int[][] label_ret, int[][] start_ret, int[][] count_ret, int[] perm) {
int l = prob.l;
int max_nr_class = 16;
int nr_class = 0;
int[] label = new int[max_nr_class];
int[] count = new int[max_nr_class];
... | 8 |
private String formatUrlParameters() {
List<String> params = new ArrayList<String>();
if (size != DEFAULT_SIZE)
params.add("s=" + size);
if (rating != DEFAULT_RATING)
params.add("r=" + rating.getCode());
if (defaultImage != GravatarDefaultImage.GRAVATAR_ICON)
params.add("d=" + defaultImage.getCode());... | 4 |
private void compute_pcm_samples6(Obuffer buffer)
{
final float[] vp = actual_v;
//int inc = v_inc;
final float[] tmpOut = _tmpOut;
int dvp =0;
// fat chance of having this loop unroll
for( int i=0; i<32; i++)
{
final float[] dp = d16[i];
float pcm_sample;
pcm_sample = (float)(((vp[6 + d... | 1 |
private void modifyCard(){
Card c;
int index;
System.out.println("Enter the index of the card you want to modify:");
index = sc.nextInt();
sc.nextLine();
c = this.deck.searchCard(index);
if(c != null){
if(c instanceof EnergyCard){
this.deck.modifyCard(this.addEnergyCard(),index);
}else ... | 4 |
public int TreeHeigh(TreeNode root) {
if(root == null) {
return 0;
}
if(root.left == null && root.right == null) {
return 1;
}
int leftHeigh = TreeHeigh(root.left);
int rightHeigh = TreeHeigh(root.right);
if(leftHeigh == -1 || rightHeigh == -1) {
return -1;
}
if(Math.abs(leftHeigh-rightHeigh)... | 7 |
private void acao128(Token token) throws SemanticError {
try {
idAtual = tabela.get(token.getLexeme(), nivelAtual);
if(idAtual instanceof IdentificadorConstante && !indexandoVetorParametro)
parametroAtualPodeSerReferencia = false;
if(idAtual instanceof IdentificadorVariavelCampoRegistro)
thro... | 4 |
private void drawColoredText(Graphics2D g, String text, int chatType, int startX, int y) {
int currentX = startX;
g.setColor(colorForChatType(chatType));
Pattern pattern = Pattern.compile("<(.*?)>");
Matcher matcher = pattern.matcher(text);
int foundMatches = 0;
int[] ... | 4 |
public void layoutContainer(Container parent) {
//System.err.println("layoutContainer");
synchronized (parent.getTreeLock()) {
Insets insets = parent.getInsets();
int ncomponents = parent.getComponentCount();
int nrows = getRows();
int ncols = getColumns();
if (ncomponents == 0) {
... | 8 |
public void printMap()
{
System.out.println("Map Dimensions: [" + x + ", " + y + "]");
for(int i = 0; i < height; i++)
{
System.out.print("[");
for(int j = 0; j < width; j++)
{
System.out.print(grid[j][i] + ", ");
}
... | 2 |
private void processFile(File file) throws IOException {
String name = file.getName();
String absPath = file.getAbsolutePath();
String newAbsPath = absPath.replace(REMOVE_FROM_PATH, "");
File newFile = new File(newAbsPath);
log.fine("NEW ABS PATH = " + newAbsPath);
if (name == null || name.length() == 0 ||
... | 8 |
Subsets and Splits
SQL Console for giganticode/java-cmpx-v1
The query retrieves a limited number of text entries within a specific length range, providing basic filtering but minimal analytical insight.