method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
27774370-d5d3-427d-9d0e-e683e642caa5 | 7 | public static ByteBuffer decode(PDFObject dict, ByteBuffer buf,
PDFObject params) throws IOException {
Inflater inf = new Inflater(false);
int bufSize = buf.remaining();
// copy the data, since the array() method is not supported
// on raf-based ByteBuffers
byte[] data = new byte[bufSize];
buf.get(data);
// set the input to the inflater
inf.setInput(data);
// output to a byte-array output stream, since we don't
// know how big the output will be
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] decomp = new byte[bufSize];
int loc = 0;
int read = 0;
try {
while (!inf.finished()) {
read = inf.inflate(decomp);
if (read <= 0) {
// System.out.println("Read = " + read + "! Params: " + params);
if (inf.needsDictionary()) {
throw new PDFParseException("Don't know how to ask for a dictionary in FlateDecode");
} else {
// System.out.println("Inflate data length=" + buf.remaining());
return ByteBuffer.allocate(0);
// throw new PDFParseException("Inflater wants more data... but it's already here!");
}
}
baos.write(decomp, 0, read);
}
} catch (DataFormatException dfe) {
throw new PDFParseException("Data format exception:" + dfe.getMessage());
}
// return the output as a byte buffer
ByteBuffer outBytes = ByteBuffer.wrap(baos.toByteArray());
// undo a predictor algorithm, if any was used
if (params != null && params.getDictionary().containsKey("Predictor")) {
Predictor predictor = Predictor.getPredictor(params);
if (predictor != null) {
outBytes = predictor.unpredict(outBytes);
}
}
return outBytes;
} |
9cbd0df5-5780-4064-a0cd-01a3f6b3affe | 9 | protected String readString(InputStream in) throws IOException {
int length = readInt(in);
// Avoid allocating a rediculous array size.
// But InputStreams don't universally track position/size.
// And available() might only mean blocking, not the end.
// So try some special cases...
if ( in instanceof FileInputStream ) {
FileInputStream fin = (FileInputStream)in;
long position = fin.getChannel().position();
if ( length > fin.getChannel().size() - position)
throw new RuntimeException( "Expected string length ("+ length +") would extend beyond the end of the stream, from current position ("+ position +")" );
}
else {
// Call available on streams that really end.
int remaining = -1;
if ( in instanceof MappedDatParser.ByteBufferBackedInputStream ) {
remaining = ((MappedDatParser.ByteBufferBackedInputStream)in).available();
}
else if ( in instanceof ByteArrayInputStream ) {
remaining = ((ByteArrayInputStream)in).available();
}
if (remaining != -1 && length > remaining )
throw new RuntimeException( "Expected string length ("+ length +") would extend beyond the end of the stream" );
}
int numRead = 0;
int offset = 0;
byte[] strarr = new byte[length];
while (offset < strarr.length && (numRead = in.read(strarr, offset, strarr.length)) >= 0)
offset += numRead;
if ( offset < strarr.length )
throw new RuntimeException( "End of stream reached before reading enough bytes for string of length "+ length );
return new String(strarr);
} |
c2d71879-f72c-4677-a461-2bce1998d02d | 4 | public final void loadAssetDetailsFromXml(String... xmlFilePaths) {
XStream xstream = new XStream(new DomDriver());
for (String xmlFilePath : xmlFilePaths) {
String xmlContents = FileManager.getFileContents(xmlFilePath);
// Cast the xml contents to the same as our data field
Map<String, Map<String, String>> parsedData = (Map<String, Map<String, String>>) xstream.fromXML(xmlContents);
// Iterate through the new data and ensure there are not duplicate
// asset names. If there are, give an error and don't add the asset.
// Otherwise add the asset details as expected
for (String newAssetKey : parsedData.keySet()) {
// If we have an asset with the same name, throw an exception
if (data.containsKey(newAssetKey)) {
logger.error(new IllegalArgumentException(), "Duplicate key value for assetname '",
newAssetKey, "' asset NOT added. Original value kept");
} else if (!parsedData.get(newAssetKey).containsKey("fileLocation")) {
// If there was no file location specified within the asset,
// give an exception
logger.error(new NullPointerException(),
"Loaded XML did not have expected fileLocation field! asset name :: ", newAssetKey);
} else {
// If the data has both a unique asset name and a file
// location add it to our hashmap of data
data.put(newAssetKey, parsedData.get(newAssetKey));
}
}
}
} |
4c454195-8797-4b72-bae4-e74f1ffc4c2d | 2 | public GraphicsMain() {
setMinimumSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE));
setMaximumSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE));
setPreferredSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE));
setIgnoreRepaint(true);
frame = new JFrame(Main.NAME);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(new BorderLayout());
frame.add(this, BorderLayout.CENTER);
frame.addKeyListener(Main.listener);
frame.pack();
frame.setResizable(false);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
if((Main.player.getX() - (WIDTH/ZOOM)/2) > 0) {
viewX = (Main.player.getX() - (WIDTH/ZOOM)/2) ;
}
else {
viewX = 0;
}
if((Main.player.getY() - (HEIGHT/ZOOM)/2) > 0) {
viewY = (Main.player.getY() - (HEIGHT/ZOOM)/2) ;
}
else {
viewY = 0;
}
} |
dc2fcdf3-ce7c-4914-aa8a-6310d9a4d191 | 9 | public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
String line;
String viewName = null;
EditorHelper editor = EditorHelper.getCurrent(event);
int lineNo = editor.getCurrentLineNo();
line = editor.getLine(lineNo);
if (line.contains("render")) {
Pattern pt = Pattern.compile("\"(.*)\"");
Matcher m = pt.matcher(line);
if (m.find()) {
// There is a custom view
viewName = m.group().replace("\"", "");
} else {
// No custom view, let's go up until we get the action name
while (lineNo > 0 && viewName == null) {
line = editor.getLine(lineNo--);
if (line.contains("public") && line.contains("static") && line.contains("void")) {
Pattern pt2 = Pattern.compile("\\w+\\s*\\(");
Matcher m2 = pt2.matcher(line);
if (m2.find()) {
String action = m2.group().replace("(", "").trim();
String controllerName = editor.getTitle().replace(".java", "");
viewName = controllerName + "/" + action + ".html";
}
}
}
}
}
if (viewName == null) {
MessageDialog.openInformation(
window.getShell(),
"Playclipse",
"Use this command in a controller, on a render() line");
} else {
(new Navigation(editor)).goToView(viewName);
}
return null;
} |
48775d56-d24f-4fe4-a1c2-9e0b6367c78c | 3 | void attackBot(BattleBot bot) {
//Check what bot is attacking, subtract health accordingly. Set victor if a bot dies.
if (bot == bot1) {
this.hpBot2--;
if (this.hpBot2 <= 0) {
this.victor = 1;
}
}
else
{
this.hpBot1--;
if (this.hpBot1 <= 0) {
this.victor = 2;
}
}
} |
068bd1d6-3911-4921-93a0-3f651d5567e3 | 9 | int insertKeyRehash(long val, int index, int hash, byte state) {
// compute the double hash
final int length = _set.length;
int probe = 1 + (hash % (length - 2));
final int loopIndex = index;
int firstRemoved = -1;
/**
* Look until FREE slot or we start to loop
*/
do {
// Identify first removed slot
if (state == REMOVED && firstRemoved == -1)
firstRemoved = index;
index -= probe;
if (index < 0) {
index += length;
}
state = _states[index];
// A FREE slot stops the search
if (state == FREE) {
if (firstRemoved != -1) {
insertKeyAt(firstRemoved, val);
return firstRemoved;
} else {
consumeFreeSlot = true;
insertKeyAt(index, val);
return index;
}
}
if (state == FULL && _set[index] == val) {
return -index - 1;
}
// Detect loop
} while (index != loopIndex);
// We inspected all reachable slots and did not find a FREE one
// If we found a REMOVED slot we return the first one found
if (firstRemoved != -1) {
insertKeyAt(firstRemoved, val);
return firstRemoved;
}
// Can a resizing strategy be found that resizes the set?
throw new IllegalStateException("No free or removed slots available. Key set full?!!");
} |
82b73ff0-e11f-4e31-86d7-6a9e59278732 | 0 | public JButton getjButtonSuiv() {
return jButtonSuiv;
} |
ccde6b9a-6b9a-472a-875b-01fc63294854 | 0 | public User getUser() {
return m_user;
} |
99a0deb2-85d9-4ddf-8a72-e7b77e29dd45 | 5 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
PII other = (PII) obj;
if (a != other.a)
return false;
if (b != other.b)
return false;
return true;
} |
f89913b4-ef42-441b-afe5-e7d0052a8b3c | 2 | public AnnotationVisitor visitArray(final String name) {
buf.setLength(0);
appendComa(valueNumber++);
if (name != null) {
buf.append(name).append('=');
}
buf.append('{');
text.add(buf.toString());
TraceAnnotationVisitor tav = createTraceAnnotationVisitor();
text.add(tav.getText());
text.add("}");
if (av != null) {
tav.av = av.visitArray(name);
}
return tav;
} |
17e92a80-87f6-4d07-bafd-dc67399eb567 | 6 | final String _readKey_(int symbol) throws IOException, IllegalArgumentException {
final Reader source = this._reader_;
final StringBuilder result = this._builder_;
result.setLength(0);
while (true) {
switch (symbol) {
case -1:
case '\r':
case '\n':
throw new IllegalArgumentException();
case '=':
return result.toString();
case '\\':
symbol = this._readSymbol_(source.read());
}
result.append((char)symbol);
symbol = source.read();
}
} |
0e99f084-3159-47dc-86f9-95b4905255a7 | 7 | Space[][] openSets(Space sp) {
Space[][] sets = new Space[numOpenSets(sp)][5];
int index = 0;
if (numOpenSets(sp) != 0) {
if (isOpen(board[sp.pos[0]], sp.piece, 1)) {
sets[index] = board[sp.pos[0]];
index++;
}
if (isOpen(getColumn(sp.pos[1]), sp.piece, 1)) {
sets[index] = getColumn(sp.pos[1]);
index++;
}
if (sp.diagID % 2 == 0
&& isOpen(topDownDiag(), sp.piece, 1)) {
sets[index] = topDownDiag();
index++;
}
if (sp.diagID % 3 == 0
&& isOpen(bottomUpDiag(), sp.piece, 1)) {
sets[index] = bottomUpDiag();
index++;
}
}
return sets;
} |
b5a2468d-fd5c-43b4-a2ff-9ca79d6e3576 | 8 | private boolean isConnectableInternal(Neighborhood n1, Neighborhood n2) {
if (n1.getCenter().equals(n2.getCenter())) {
return false;
}
final LineSegmentInt seg1 = new LineSegmentInt(n1.getCenter(), n2.getCenter());
if (hasIntersectionStrict(seg1)) {
return false;
}
final double angle1 = Singularity.convertAngle(seg1.getAngle());
final double angle2 = Singularity.convertAngle(seg1.getOppositeAngle());
assert angle2 == Singularity.convertAngle(new LineSegmentInt(n2.getCenter(), n1.getCenter()).getAngle());
if (n1.isInAngleStrict(angle1) && n2.isInAngleStrict(angle2)) {
return true;
}
if (n1.isAngleLimit(angle1) && n2.isAngleLimit(angle2)) {
if (n1.is360() || n2.is360()) {
return true;
}
final Orientation o1 = n1.getOrientationFrom(angle1);
final Orientation o2 = n2.getOrientationFrom(angle2);
return o1 != o2;
}
return false;
} |
79926d30-7a06-4708-b54c-28c335c1a482 | 0 | public void setIterationCount(BigInteger value) {
this.iterationCount = value;
} |
f0a3f1d7-3533-463b-b916-7ff27ea63e48 | 9 | @Override
public boolean equals(Object obj) {
if (!(obj instanceof IndexItem<?,?>)) {
return false;
}
IndexItem<? extends Annotation,?> o = (IndexItem<?,?>) obj;
return structure.equals(o.structure) && annotationType == o.annotationType && loader == o.loader;
} |
44646545-889c-4a10-82fc-9eb7d47a401f | 2 | private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
Pays paysVide = new Pays(-1,"");
this.jComboBoxPays.addItem(paysVide);
try {
List<Pays> pp1 = RequetesPays.selectPays();
for (Pays pays : pp1) {
jComboBoxPays.addItem(pays);
}
} catch (SQLException ex) {
Logger.getLogger(VueVille.class.getName()).log(Level.SEVERE, null, ex);
}
}//GEN-LAST:event_formWindowOpened |
83621d5e-9bfa-4b92-8eed-2a62395d5c5e | 7 | public ArrayList<FirstMove> makeFirstMoves(SearchPiece[] board) {
ArrayList<String> history = new ArrayList<String>();
ArrayList<FirstMove> firstmoves = new ArrayList<FirstMove>();
for (int i = 0; i < board.length; i++) {
SearchBoard move1 = new SearchBoard(board, 1, 1, i);
SearchBoard move2 = new SearchBoard(board, 1, 2, i);
move1.setBoardSize(board[0].getBoardSize());
move2.setBoardSize(board[0].getBoardSize());
move1.printBoard();
//System.out.println("");
move2.printBoard();
//System.out.println("");
String direction1;
String direction2;
if (board[i].getPieceType() == 1 || board[i].getPieceType() == 2)
direction1 = "Left";
else
direction1 = "Up";
if (board[i].getPieceType() == 1 || board[i].getPieceType() == 2)
direction2 = "Right";
else
direction2 = "Down";
if (move1.isLegalBoard()) {
FirstMove firstmove1 = new FirstMove(move1, i, 1, direction1,history);
firstmoves.add(firstmove1);
history=firstmove1.getHistory();
}
if (move2.isLegalBoard()) {
FirstMove firstmove2 = new FirstMove(move2, i, 1, direction2,history);
firstmoves.add(firstmove2);
history=firstmove2.getHistory();
}
}
return firstmoves;
} |
0b996e70-ae1a-4e37-b52f-c1d71f18a0cf | 8 | public static int getAuctionTime( int auctionID ) throws DatabaseException {
Connection conn = null;
ResultSet rs = null;
PreparedStatement ps = null;
int uid, bids;
String qGetAuctionTime = "SELECT endingTime FROM auctiontime WHERE auctionID = ?";
try {
conn = DBPool.getInstance().getConnection();
//////////////////////////////
ps = conn.prepareStatement( qGetAuctionTime );
ps.setInt( 1, auctionID );
rs = ps.executeQuery();
if ( rs.next() ) {
return rs.getInt( "endingTime" );
}
else {
throw new IllegalStateException( "Can't get endingTime" );
}
//////////////////////////////
}
catch ( SQLException e ) {
System.out.println( "bridge " + e.toString() + e.getStackTrace() );
throw new DatabaseException( e.toString() );
}
finally {
try { if (rs != null) rs.close(); } catch(Exception e) { }
try { if (ps != null) ps.close(); } catch(Exception e) { }
try { if (conn != null) conn.close(); } catch(Exception e) { }
}
} |
bee6ccd2-ddf3-4a37-ba5a-ed0ed11dfa86 | 8 | public List<Pixel> neighbours(int width, int height)
{
List<Pixel> result = new ArrayList<Pixel>(8);
for(int i = -1; i <= 1; i++)
{
for(int j = -1; j <= 1; j++)
{
if(i != 0 || j != 0)
{
int newX = x + i;
int newY = y + j;
if(newX >= 0 && newX < width && newY >= 0 && newY < height)
{
result.add(new Pixel(newX,newY));
}
}
}
}
return result;
} |
f0881c9f-77ce-4631-a7bf-a02796274276 | 5 | private void listar_Impresoras (){
String [] separada;
separada = jComboBox1.getSelectedItem().toString().split("-");
int modulo = Integer.parseInt(separada[0].trim());
r_con.Connection();
Vector<Vector<String>>v = r_con.getContenidoTabla("SELECT * FROM impresoras WHERE imp_id_modulo = "+modulo);
DefaultListModel modelo = new DefaultListModel();
for(Vector<String>a:v){
modelo.addElement(a.elementAt(0));
//jComboBox1.addItem(a.elementAt(0)+" - "+a.elementAt(1));
}
v=null;
r_con.cierraConexion();
jList1.setModel(modelo);
jList1.setSelectionModel(new DefaultListSelectionModel() {
private int i0 = -1;
private int i1 = -1;
public void setSelectionInterval(int index0, int index1) {
if(i0 == index0 && i1 == index1){
if(getValueIsAdjusting()){
setValueIsAdjusting(false);
setSelection(index0, index1);
}
}else{
i0 = index0;
i1 = index1;
setValueIsAdjusting(false);
setSelection(index0, index1);
}
}
private void setSelection(int index0, int index1){
if(super.isSelectedIndex(index0)) {
super.removeSelectionInterval(index0, index1);
}else {
super.addSelectionInterval(index0, index1);
}
}
});
} |
5e9322bc-dce8-4e2a-9186-2ca4a7c4374f | 2 | public Result execute(Command command) {
LabelDTO labelDTOren = (LabelDTO) ((Object[]) command.getCommandSource())[0];
Account accountren;
accountren = accountDAO.getAccountByname(labelDTOren.getAccount());
Set<Label> labelsren = new HashSet<Label>();
labelsren = accountren.getLabel();
for (Iterator<Label> it = labelsren.iterator(); it.hasNext();) {
Label label = it.next();
if (label.getName().equals(labelDTOren.getName())) {
label.setName((String) ((Object[]) command.getCommandSource())[1]);
labelDAO.updateLabel(label);
}
}
return result;
} |
1ef3fb40-ac34-4b73-b84d-98063753c0c6 | 2 | private
List<Element> queryXPathList(String query) {
if (query == null) return new ArrayList<Element>(0);
try {
Element root = doc.getRootElement();
XPathBuilder<Element> xpb = new XPathBuilder<Element>(query,Filters.element());
XPathExpression<Element> xpe = xpb.compileWith(XPathFactory.instance()); // default factory
return xpe.evaluate(root);
} catch (NullPointerException|IllegalStateException|IllegalArgumentException e) {
Main.logger.log(Level.SEVERE,"",e);
return new ArrayList<Element>(0);
}
} |
9de9e9fb-742a-4b69-bd9e-1a4172df342f | 9 | public Matrix solve (Matrix B) {
if (B.getRowDimension() != m) {
throw new IllegalArgumentException("Matrix row dimensions must agree.");
}
if (!this.isNonsingular()) {
throw new RuntimeException("Matrix is singular.");
}
// Copy right hand side with pivoting
int nx = B.getColumnDimension();
Matrix Xmat = B.getMatrix(piv,0,nx-1);
double[][] X = Xmat.getArray();
// Solve L*Y = B(piv,:)
for (int k = 0; k < n; k++) {
for (int i = k+1; i < n; i++) {
for (int j = 0; j < nx; j++) {
X[i][j] -= X[k][j]*LU[i][k];
}
}
}
// Solve U*X = Y;
for (int k = n-1; k >= 0; k--) {
for (int j = 0; j < nx; j++) {
X[k][j] /= LU[k][k];
}
for (int i = 0; i < k; i++) {
for (int j = 0; j < nx; j++) {
X[i][j] -= X[k][j]*LU[i][k];
}
}
}
return Xmat;
} |
c321b883-9409-4d16-b6d7-5eaed6a3d27b | 6 | 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.TRUE)
|| (object instanceof String && ((String) object)
.equalsIgnoreCase("true"))) {
return true;
}
throw new JSONException("JSONObject[" + quote(key)
+ "] is not a Boolean.");
} |
aa5926db-354e-4f40-bcf3-ca7bb86fb2a2 | 7 | public boolean isLegalMovement(HantoCell from, HantoCell to, HantoBasePiece piece)throws HantoException{
boolean isLegal = true;
int cellDistance = getDistance(from, to);
if (!isAdjacent(to.getX(), to.getY())){
throw new HantoException("Cell is not adjacent");
}
if (breaksContinuity(from, to)){
throw new HantoException("Contiunity would break");
}
if(piece.getMoveType() == HantoMove.WALK)
{
if(!slideCheck(from, to))
{
throw new HantoException("Slide Moves are illegal");
}
} else if (piece.getMoveType() == HantoMove.JUMP){
if (!isStraight(from, to)){
throw new HantoException("This Piece Must Move Straight but is Not");
}
}
if (cellDistance > piece.getMoveDistance()){
throw new HantoException("Distance too far for piece");
}
return isLegal;
} |
7e8f9290-1df0-4862-8491-16c64f432c06 | 3 | @Override
public boolean performFinish() {
final String containerName = page.getContainerName();
final String fileName = page.getFileName();
IRunnableWithProgress op = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException {
try {
doFinish(containerName, fileName, monitor);
} catch (CoreException e) {
throw new InvocationTargetException(e);
} finally {
monitor.done();
}
}
};
try {
getContainer().run(true, false, op);
} catch (InterruptedException e) {
return false;
} catch (InvocationTargetException e) {
Throwable realException = e.getTargetException();
MessageDialog.openError(getShell(), "Error", realException.getMessage());
return false;
}
return true;
} |
480f9e72-53cb-4875-b8d7-c5686e5797ae | 4 | private void downloadNewTables() {
List<Integer> changes = findTableChanges();
Queue<FileRequest> requests = new LinkedList<FileRequest>();
tables = new ReferenceTable[versionTable.getEntryCount()];
for (int i = 0; i < changes.size(); i++) {
requests.offer(requester.request(255, changes.get(i)));
}
while(requests.size() > 0) {
requester.process();
for (Iterator<FileRequest> iter = requests.iterator(); iter.hasNext();) {
FileRequest request = iter.next();
if (request.isComplete()) {
int file = request.getFile();
ByteBuffer data = request.getBuffer();
tables[file] = new ReferenceTable(file, data, versionTable);
data.position(0);
reference.put(file, data, data.capacity());
iter.remove();
}
}
}
} |
17bd3dc4-5605-420e-a9c1-7b11ff1abd0c | 3 | public Image getImage(String s, Color fill) {
// check xobjects for stream
Stream st = (Stream) library.getObject(xobjects, s);
if (st == null) {
return null;
}
// return null if the xobject is not an image
if (!st.isImageSubtype()) {
return null;
}
// lastly return the images.
Image image = null;
try {
image = st.getImage(fill, this, true);
// clean up the stream's resources.
st.dispose(true);
}
catch (Exception e) {
logger.log(Level.FINE, "Error getting image by name: " + s, e);
}
return image;
} |
c329f2bb-7170-4cc1-aeab-de0a06e8f180 | 5 | final void a(int i) {
if ((mask & 0x5) != 5)
throw new IllegalStateException();
if (i == 4096)
method644();
else if (i == 8192)
method651();
else if (i == 12288)
method639();
else {
int i_578_ = Class70.sineTable[i];
int i_579_ = Class70.cosineTable[i];
synchronized (this) {
for (int i_580_ = 0; i_580_ < anInt5340; i_580_++) {
int i_581_ = ((anIntArray5312[i_580_] * i_578_
+ anIntArray5356[i_580_] * i_579_)
>> 14);
anIntArray5312[i_580_]
= (anIntArray5312[i_580_] * i_579_
- anIntArray5356[i_580_] * i_578_) >> 14;
anIntArray5356[i_580_] = i_581_;
}
method631();
}
}
} |
95c061b3-67c9-415d-ba79-ff70a9b6689d | 8 | @Override
public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel)
{
final MOB target=this.getTarget(mob,commands,givenTarget);
if(target==null)
return false;
if(!super.invoke(mob,commands,givenTarget,auto,asLevel))
return false;
final boolean success=proficiencyCheck(mob,0,auto);
if(success)
{
final CMMsg msg=CMClass.getMsg(mob,target,this,verbalCastCode(mob,target,auto),auto?"":L("^S<S-NAME> chant(s) to <T-NAMESELF>.^?"));
if(mob.location().okMessage(mob,msg))
{
mob.location().send(mob,msg);
final Ability A=target.fetchEffect("Chant_StrikeBarren");
if(A!=null)
{
if(A.invoker()==null)
A.unInvoke();
else
if(A.invoker().phyStats().level()<adjustedLevel(mob,asLevel))
A.unInvoke();
else
{
mob.tell(L("The magical barrenness upon @x1 is too powerful.",target.name(mob)));
return false;
}
}
mob.location().show(target,null,CMMsg.MSG_OK_VISUAL,L("<S-NAME> seem(s) extremely fertile!"));
beneficialAffect(mob,target,asLevel,Ability.TICKS_ALMOST_FOREVER);
}
}
else
return beneficialWordsFizzle(mob,target,L("<S-NAME> chant(s) to <T-NAMESELF>, but the magic fades."));
// return whether it worked
return success;
} |
30b60c02-b9f9-4641-b120-3f4bf7752311 | 0 | @Override
public void mouseReleased(MouseEvent e) {
mouseKeyStatus(e, false);
} |
53825bd0-8868-44cc-93a6-ea92f5497e3a | 1 | public void m1() {
try {
this.i = 10;
System.out.println("dans m1 : i = "+this.i);
this.m2(this.i);
} catch(Exception e) {
// code palliant l’erreur ayant provoqué l’exception.
}
System.out.println("catch de m1 : i = " + this.i);
} |
1411a291-2d92-4e0d-af17-b098549bd871 | 0 | public Unit(double conversionFactor, String name) {
this.conversionFactor = conversionFactor;
this.name = name;
} |
c2c62311-0bb1-459c-abd8-361815d5784c | 3 | public void run(){
byte[] b = new byte[8192];
MessageEvent me = new MessageEvent(b);
while(true){
try{
Connection.getInputStream().read(b);
Main.getDefaultEventSystem().listen(me.setBytes(b));
if(me.isCanceled())break;
}catch(Exception e){e.printStackTrace(); break;}
}
System.out.println("Reader Thread Ended!");
} |
fcdf6f95-6b35-4695-86d6-e024571ade9e | 4 | public void lisaaHoitoOhjeet(HttpServletRequest request, HttpServletResponse response) throws NamingException, SQLException, ServletException, IOException {
Kayttaja a = haeAsiakkaanTiedotAsiakasIdlla(request);
try {
List<HoitoOhje> h = new ArrayList<HoitoOhje>();
List<Oirekuvaus> o = Oirekuvaus.haeOirekuvauksetAsiakasIdlla(a.getId());
List<Integer> i = new ArrayList<Integer>();
for (HoitoOhje hoo : HoitoOhje.haeHoitoOhjeetAsiakasIdlla(a.getId())) {
i.add(hoo.getVarausId());
}
for (Oirekuvaus o1 : o) {
if (i.contains(o1.getVarausId())) {
h.add(HoitoOhje.haeHoitoOhjeVarausIdlla(o1.getVarausId()));
} else {
h.add(new HoitoOhje());
}
}
request.setAttribute("hoitoOhjeet", h);
} catch (Exception e) {
naytaVirheSivu("Hoito-ohjeiden haku tietokannasta epäonnistui.", request, response);
}
} |
9126ef56-29cf-48a9-82eb-1a68aa6b3016 | 3 | public int executeUpdate(String sql,List params) {
int result = -1;
try {
//执行SQL语句
PreparedStatement ps = connection.prepareStatement(sql);
if(params != null)
for(int i = 0 ;i < params.size();i++){
ps.setObject(i+1,params.get(i));
}
result = ps.executeUpdate();
} catch (Exception e) {
//throw new QueryException(e.getMessage());
logger.error(e.getMessage());
throw e;
}finally {
return result;
}
} |
af6ba2c0-a757-4331-b81c-773e4ff234f2 | 3 | public static void sort(long[]arr){
long tmp = 0;
for(int i=1;i<arr.length;i++){
tmp = arr[i];
int j=i;
while(j>0 && arr[j] >= tmp){
arr[j] = arr[j - 1];
j--;
}
arr[j] = tmp;
}
} |
0d93f329-cc16-4642-82f7-6cce6b98cf97 | 3 | public JSONWriter object() throws JSONException {
if (this.mode == 'i') {
this.mode = 'o';
}
if (this.mode == 'o' || this.mode == 'a') {
this.append("{");
this.push(new JSONObject());
this.comma = false;
return this;
}
throw new JSONException("Misplaced object.");
} |
0fc7680b-2cb5-474b-9b68-f3d193634ccf | 7 | public void merge(int a[], int m, int b[], int n) {
int aIndex = m - 1, bIndex = n - 1;
for (int i = m + n - 1; i >= 0; i --) {
Integer aItem = aIndex >= 0 ? a[aIndex] : null;
Integer bItem = bIndex >= 0 ? b[bIndex] : null;
boolean fromB = false;
if (aIndex < 0) {
fromB = true;
} else if (bIndex < 0) {
fromB = false;
} else if (a[aIndex] < b[bIndex]) {
fromB = true;
} else {
fromB = false;
}
if (fromB) {
a[i] = bItem;
bIndex --;
} else {
a[i] = aItem;
aIndex --;
}
}
} |
850f0641-0fd5-43db-95cd-ee8cea3740df | 3 | public static void Initialize(int width, int height){
if(GRASS == null)
GRASS = new Tile(width, height, true, 0xff45ef45);
if(WALL == null)
WALL = new Tile(width, height, false, 0xff121212);
if(HERO == null)
HERO = new Tile(width - 4, height - 4, false, 0xffef4545);
} |
b07567ca-67fa-44b7-8209-983aae8cdced | 1 | @Override
public void visitConstantExpr(ClassNode c, MethodNode m, final ConstantExpr expr) {
if (expr.value() instanceof Type) {
Type typeValue = (Type) expr.value();
String name = typeValue.toString().replaceAll("/", ".").replaceFirst("L", "").replace(";", "");
CallStaticExpr forName = new CallStaticExpr(new Expr[] { new ConstantExpr(name, Type.STRING) }, new MemberRef(Type.CLASS, new NameAndType("forName", Type.getType(new Type[] { Type.STRING }, Type.CLASS))), Type.CLASS);
expr.replaceWith(forName);
count++;
}
} |
f4369883-48b6-4c4a-ae2b-a57c7d8d735b | 8 | @Override
public int[] getInts(int par1, int par2, int par3, int par4)
{
int i1 = par1 - 1;
int j1 = par2 - 1;
int k1 = par3 + 2;
int l1 = par4 + 2;
int[] aint = this.parent.getInts(i1, j1, k1, l1);
int[] aint1 = IntCache.getIntCache(par3 * par4);
for (int i2 = 0; i2 < par4; ++i2)
{
for (int j2 = 0; j2 < par3; ++j2)
{
int k2 = aint[j2 + 0 + (i2 + 0) * k1];
int l2 = aint[j2 + 2 + (i2 + 0) * k1];
int i3 = aint[j2 + 0 + (i2 + 2) * k1];
int j3 = aint[j2 + 2 + (i2 + 2) * k1];
int k3 = aint[j2 + 1 + (i2 + 1) * k1];
this.initChunkSeed(j2 + par1, i2 + par2);
if (k3 == 0 && k2 == 0 && l2 == 0 && i3 == 0 && j3 == 0 && this.nextInt(100) == 0)
{
aint1[j2 + i2 * par3] = BiomeGenBase.mushroomIsland.biomeID;
}
else
{
aint1[j2 + i2 * par3] = k3;
}
}
}
return aint1;
} |
5106f0bf-3c34-42bd-b616-23641149a194 | 1 | @Override
public void scoreRound(boolean won, int score) {
//If we won the round, update the weights for reinforcement learning
if (won) updateWeights();
} |
8a8c5919-fa3a-409c-922e-2ff7c4de2ac7 | 4 | public static void putOnStack(Node[] state, char player){
double[] ourState = new double[state.length * 2];
//put in the x's
for(int i = 0; i < 48; i++){
if(state[i].getChar() == 'x'){
ourState[i] = 1;
}
else{
ourState[i] = 0;
}
}
//put in the o's
for(int i = 48; i < input.length-1; i++){
if(state[i - 48].getChar() == 'o'){
ourState[i] = 1;
}
else{
ourState[i] = 0;
}
}
gameStack.push(ourState);
} |
e3eeb613-5aa7-4470-a9ec-8e1b9eef9043 | 0 | public InetAddress getAddress() {
return this.address;
} |
98e0ed6c-2f41-488b-a0ec-730ac4b9c8ad | 6 | public void testSafeAddLong() {
assertEquals(0L, FieldUtils.safeAdd(0L, 0L));
assertEquals(5L, FieldUtils.safeAdd(2L, 3L));
assertEquals(-1L, FieldUtils.safeAdd(2L, -3L));
assertEquals(1L, FieldUtils.safeAdd(-2L, 3L));
assertEquals(-5L, FieldUtils.safeAdd(-2L, -3L));
assertEquals(Long.MAX_VALUE - 1, FieldUtils.safeAdd(Long.MAX_VALUE, -1L));
assertEquals(Long.MIN_VALUE + 1, FieldUtils.safeAdd(Long.MIN_VALUE, 1L));
assertEquals(-1, FieldUtils.safeAdd(Long.MIN_VALUE, Long.MAX_VALUE));
assertEquals(-1, FieldUtils.safeAdd(Long.MAX_VALUE, Long.MIN_VALUE));
try {
FieldUtils.safeAdd(Long.MAX_VALUE, 1L);
fail();
} catch (ArithmeticException e) {
}
try {
FieldUtils.safeAdd(Long.MAX_VALUE, 100L);
fail();
} catch (ArithmeticException e) {
}
try {
FieldUtils.safeAdd(Long.MAX_VALUE, Long.MAX_VALUE);
fail();
} catch (ArithmeticException e) {
}
try {
FieldUtils.safeAdd(Long.MIN_VALUE, -1L);
fail();
} catch (ArithmeticException e) {
}
try {
FieldUtils.safeAdd(Long.MIN_VALUE, -100L);
fail();
} catch (ArithmeticException e) {
}
try {
FieldUtils.safeAdd(Long.MIN_VALUE, Long.MIN_VALUE);
fail();
} catch (ArithmeticException e) {
}
} |
17e037a1-c91b-4f09-a64e-b145f63633c7 | 7 | public boolean interact(Widget w, Coord c) {
for (Widget wdg = w.lchild; wdg != null; wdg = wdg.prev) {
if (wdg == this)
continue;
Coord cc = w.xlate(wdg.c, true);
if (c.isect(cc, (wdg.hsz == null) ? wdg.sz : wdg.hsz)) {
if (interact(wdg, c.add(cc.inv())))
return (true);
}
}
if (w instanceof DTarget) {
if (((DTarget) w).iteminteract(c, c.add(doff.inv())))
return (true);
}
return (false);
} |
50a5092c-282f-471a-b55f-f73c37789d8f | 7 | 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://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(QATracker.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(QATracker.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(QATracker.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(QATracker.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
try {
new QATracker().setVisible(true);
} catch (SQLException ex) {
Logger.getLogger(QATracker.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
} |
27c3dee8-47b7-4c17-a6b9-a798fb6a118d | 7 | private boolean agregarALista(NodoTablaHashing<K,V>[] aP, K k, V v) {
int llave=hash(k);
boolean bool=false;
if(aP[hash(k)]!=null){
int i=llave;
while(i<aP.length&&!bool){
if(aP[i]==null){
aP[i]=new NodoTablaHashing<K, V>(k, v); bool=true;
}
i++;
}
for(int j=0;j<llave&&!bool;j++){
if(aP[j]==null){
aP[j]=new NodoTablaHashing<K, V>(k, v); bool=true;
}
}
}
else{
aP[llave]=new NodoTablaHashing<K, V>(k, v); bool=true;
}
return bool;
} |
b62b3628-983f-4abe-a232-a8f8a9cacea9 | 8 | private int gameValue() {
// Calculate the base value for the game
int baseVal = 24; // start off with grand game value.
// Grab our gametype, and if it's not grand, calculate the values.
GameTypeOptions.GameType actualGameType = this.gameType.getGameType();
if(actualGameType != GameTypeOptions.GameType.Grand) {
// If it's a suit game, set the values
if(actualGameType == GameTypeOptions.GameType.Suit) {
// Get the index of our option, and subtract 1 since we won't have the first None option.
int trumpSuitIndex = this.gameType.getTrumpSuit().ordinal() - 1;
// Our enum options are descending in terms of base value from 12.
baseVal = 12 - trumpSuitIndex;
}
else
{
// Grab some options used to calculate base value for Null.
boolean optHand = (this.gameType.getHandType() == GameTypeOptions.SkatHandType.Hand);
boolean optOuvert = this.gameType.getOuvert();
// Calculate our base value based off these options..
if(!optHand && !optOuvert)
// Null
baseVal = 23;
else if(optHand && !optOuvert)
// Null Hand
baseVal = 35;
else if(!optHand && optOuvert)
// Null Ouvert
baseVal = 46;
else
// Null Ouvert Hand
baseVal = 59;
}
}
// Return the game value.
return baseVal * multiplier;
} |
bc70a742-97d4-499e-a510-4a6b8180b365 | 0 | public DotMessageShower(String message,IOnStringInput onStringInput) {
super(message,SYMBOL,onStringInput);
} |
6d6653a3-a34c-4ac5-9531-2a34068333cc | 6 | public Item(GameWindow w, int x, int y, int type){
window = w;
panel = w.panel;
energy =100;
posX =x;
posY =y;
bounds = new Rectangle(posX,posY,32,32);
itemType = type;
switch(itemType){
case(0): //Waffe
damage = 1;
name = "Magnum";
break;
case(1): //medikit, nahrung
healthPts = 10;
name = "Medikit";
break;
case(2): //ammo
shots = 10;
name = "Ammo";
break;
case(3): //div objekt
healthPts = 5;
name = "Pills";
break;
case(4):
money = 20;
name = "some money";
break;
case(5):
money =30;
name = "some money";
break;
}
img = window.itemHandler.picturesOfAllItems[itemType];
invMiniImg = window.itemHandler.picturesInventory[itemType];
} |
9d99c5dd-28ff-4ba6-9a88-5e380265d377 | 6 | public void drawCell(int x, int y){
/* Cell Drawing Option
* 0 = Regular drawing
* 1 = Checker Board pattern
* 2 = Randomized
* 3 = Randomized/Checker Board
*/
if(rcflag){if(cdo == 1){ cellCheckDraw(x,y, true);}else{cellAltDraw(x,y);}}
else{
switch(cdo){
case 0: cellDraw(x,y); break;
case 1: cellCheckDraw(x,y, false); break;
case 2: cellRandDraw(x,y); break;
case 3: cellRCDraw(x,y); break;
default: cellDraw(x,y); break;}}
} |
f84d2323-dc51-4021-be77-67e5d890c39f | 0 | public int value() {
return i;
} |
73b574f6-03ef-4001-9c32-d0195cdfd2b3 | 1 | public double value(double x) {
if (Double.isNaN(this.Demand.density(x))) System.out.println(
"NaN Density at "+x+" of "+Demand+" with mean "+Demand.getNumericalMean()+
" and sd "+Math.sqrt(Demand.getNumericalVariance()));
return (this.y-x)*this.Demand.density(x);
} |
3a488b65-3b95-46ab-834c-9c834f073fec | 3 | public static List<Block> getBlocks(Cuboid cuboid, World world){
List<Block> blocks = new ArrayList<Block>();
for(int x = cuboid.getVectorMin().getBlockX(); x <= cuboid.getVectorMax().getBlockX(); x++){
for(int y = cuboid.getVectorMin().getBlockY(); y <= cuboid.getVectorMax().getBlockY(); y++){
for(int z = cuboid.getVectorMin().getBlockZ(); z <= cuboid.getVectorMax().getBlockZ(); z++){
blocks.add(world.getBlockAt(x, y, z));
}
}
}
return blocks;
} |
75c9765e-4516-4656-ab3c-45daefbeae38 | 8 | public int getNeighbourIndex(final Direction direction, final Cell cell, final Player player) {
switch (direction) {
case TOP:
return verticalMoveChecker.getTopNeighbourIndex(cell, player);
case BOTTOM:
return verticalMoveChecker.getBottomNeighbourIndex(cell, player);
case LEFT:
return horizontalMoveChecker.getLeftNeighbourIndex(cell, player);
case RIGHT:
return horizontalMoveChecker.getRightNeighbourIndex(cell, player);
case MAIN_DIAGONAL_BOTTOM:
return mainDiagonalMoveChecker.getBottomNeighbourIndex(cell, player);
case MAIN_DIAGONAL_TOP:
return mainDiagonalMoveChecker.getTopNeighbourIndex(cell, player);
case SECONDARY_DIAGONAL_BOTTOM:
return secondaryDiagonalMoveChecker.getBottomNeighbourIndex(cell, player);
case SECONDARY_DIAGONAL_TOP:
return secondaryDiagonalMoveChecker.getTopNeighbourIndex(cell, player);
default:
return -1;
}
} |
8d9ba6e4-ce52-4534-9060-72e2dfdca2d1 | 6 | @Override
public boolean removeLetterTiles(List<Location> tilesPlayed) {
if(tilesPlayed == null) return true;
List<Tile> removedTiles = new ArrayList<Tile>();
for(Location loc : tilesPlayed){
Tile t = loc.getTile();
if(t==null){
throw new NullPointerException("Can't remove null tile from player");
}
Iterator<Tile> it = letters.iterator();
boolean removed = false;
while(it.hasNext()){
Tile next = it.next();
if(next.getName().equals(t.getName())){
it.remove();
removedTiles.add(next);
removed = true;
break;
}
}
if(!removed){
letters.addAll(removedTiles);
return false;
}
}
return true;
} |
a081ee0b-ebac-4076-aa96-89420062171e | 2 | public static void changeSetting(String key, String newValue) {
//Check if the key exists, if so; remove it
if (configuration.containsKey(key) && !configuration.get(key).equals(newValue)) {
Logger.log("Removed: " + key);
configuration.remove(key);
}
//Put in the new value
configuration.put(key, newValue);
//And save the settings
saveSettings();
} |
024b8011-d755-43a6-a6c0-187c4c2e325d | 8 | public DonkeyRegion(File hardFile) {
this.hardFile = hardFile;
try {
if (hardFile.exists()) {
lastModification = hardFile.lastModified();
}
file = new RandomAccessFile(hardFile, "rw");
if (file.length() < 5) {
// Write the Donkeychunk magic
file.writeByte(0x44);
file.writeByte(0x4e);
file.writeByte(0x4b);
// Write the version
file.writeByte(version);
// Write the default flags
file.writeByte(getFlags());
}
if (file.length() < 7173) {
// Write a blank location map
file.write(new byte[7168]);
}
file.seek(0L);
if (!(file.readByte() == 0x44 && file.readByte() == 0x4e && file.readByte() == 0x4b)) {
throw new NotADonkeyException("Donkeychunk signature invalid");
}
version = file.readByte();
if (version > DonkeyConstants.DONKEY_VERSION) {
throw new UnsupportedDonkeyException("Unsupported Donkeychunk version (region: " + version + ", library: " + DonkeyConstants.DONKEY_VERSION + ")");
}
byte flags = file.readByte();
hasChunkTimestamps = (flags & 15) > 7;
hasChunkCompression = (flags >> 4 & 15) > 7;
} catch (IOException ex) {
throw new NotADonkeyException(ex);
}
} |
658f3afa-5b4a-4861-9ee8-6084d92da225 | 9 | @Override
public boolean process(Player player) {
if (ingredients == Ingredients.TORSTOL && otherItem.getId() != VIAL) {
if (!player.getInventory().containsOneItem(15309)
|| !player.getInventory().containsOneItem(15313)
|| !player.getInventory().containsOneItem(15317)
|| !player.getInventory().containsOneItem(15321)
|| !player.getInventory().containsOneItem(15325))
return false;
}
if (!player.getInventory().containsItem(node.getId(), node.getAmount())
|| !player.getInventory().containsItem(otherItem.getId(),
otherItem.getAmount())) {
return false;
}
return true;
} |
33885bd8-1d68-4b6f-9eae-a46b6822681b | 1 | @Override
public void handleResult() throws InvalidRpcDataException {
String result = getStringResult();
if (result.equalsIgnoreCase(STATUS_STRING_OK)) {
EventBusFactory.getDefault().fire(new DownloadRemovedEvent(downloadGid));
} else {
// TODO: handle
Arietta.handleException(new Exception("Got unexpected result"));
}
} |
4f10e5c8-ff08-49b5-9dbb-830353d49cfe | 7 | public boolean isValid(String s) {
if (s == null || s.length() <= 1) {
return false;
}
Map<Character, Character> map = new HashMap<Character, Character>();
map.put('(', ')');
map.put('[', ']');
map.put('{', '}');
Stack<Character> stack = new Stack<Character>();
for (char c : s.toCharArray()) {
if (map.keySet().contains(c)) {
stack.push(c);
} else if (map.values().contains(c) && !stack.isEmpty() && map.get(stack.peek()).equals(c)) {
stack.pop();
} else {
return false;
}
}
return stack.isEmpty();
} |
21c46564-3a9b-4f48-807a-a9c815d3af72 | 9 | public static BufferedImage detectVerticalEdges(BufferedImage image, int amount) {
int width = image.getWidth();
int height = image.getHeight();
BufferedImage edgeImage = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_GRAY);
for(int x = 0; x < width; x++)
for(int y = 0; y < height; y++ )
edgeImage.setRGB(x, y, WHITE);
for(int x = amount/2; x < width-amount/2; x++) {
for(int y = amount/2; y < height-amount/2; y++) {
int sum1 = 0;
int sum2 = 0;
for(int h = x-amount/2; h < x; h++) {
for(int i = y-amount/2; i <= y+amount/2; i++) {
sum1 += image.getRGB(h, i) & 0x000000FF;
}
}
for(int h = x+1; h <= x+amount/2; h++) {
for(int i = y-amount/2; i <= y+amount/2; i++) {
sum2 += image.getRGB(h, i) & 0x000000FF;
}
}
sum2 = sum2 * -1;
sum1 = Math.abs(sum1 + sum2);
if(sum1 > THRESHOLD) {
edgeImage.setRGB(x, y, BLACK);
}
}
}
return edgeImage;
} |
50a442c4-4ed4-4d7f-83e7-ecd68d795085 | 2 | public double getEtxToMeFromNode(int nodeID) {
Iterator<Edge> it2 = this.outgoingConnections.iterator();
EdgeOldBetEtx e;
while (it2.hasNext()) {
e = (EdgeOldBetEtx) it2.next();
if (e.endNode.ID == nodeID){
e = (EdgeOldBetEtx) e.getOppositeEdge();
return e.getEtx();
}
}
return 0.0;
} |
39d6549a-ccce-47ed-91ec-05d976b06595 | 9 | public InputStream pcmstream() {
return(new InputStream() {
private byte[] buf;
private int bufp;
private boolean convert() throws IOException {
float[][] inb = decode();
if(inb == null) {
buf = new byte[0];
return(false);
}
buf = new byte[2 * chn * inb[0].length];
int p = 0;
for(int i = 0; i < inb[0].length; i++) {
for(int c = 0; c < chn; c++) {
int s = (int)(inb[c][i] * 32767);
buf[p++] = (byte)s;
buf[p++] = (byte)(s >> 8);
}
}
bufp = 0;
return(true);
}
public int read() throws IOException {
byte[] rb = new byte[1];
int ret;
do {
ret = read(rb);
if(ret < 0)
return(-1);
} while(ret == 0);
return(rb[0]);
}
public int read(byte[] dst, int off, int len) throws IOException {
if((buf == null) && !convert())
return(-1);
if(buf.length - bufp < len)
len = buf.length - bufp;
System.arraycopy(buf, bufp, dst, off, len);
if((bufp += len) == buf.length)
buf = null;
return(len);
}
public void close() throws IOException {
VorbisStream.this.close();
}
});
} |
1f1d8c9e-8c26-4769-8fff-fc6a1d9fc578 | 1 | @Override
public void terminateMachine(IMachine machine) throws InvalidObjectException, ConnectorException
{
try
{
CloudStackClient client = ClientLocator.getInstance().getClient(machine.getComputeCenter().getProperties(),
controllerServices);
client.terminateVirtualMachine(machine.getName());
}
catch (Exception e)
{
throw new ConnectorException("Error Terminating " + machine.getComputeCenter().getType().getName()
+ " Instance Id:" + machine.getId() + ". Error:" + e.getMessage(),e);
}
} |
40d3c9ab-d021-41ff-b04f-2068a684dd34 | 5 | public void load(Vehicle vehicle, File file){
// Load the Vehicle in Territory.
addVehicle(vehicle);
BufferedReader reader = null;
String line = "";
String splitBy = ",";
try {
reader = new BufferedReader(new FileReader(file));
while ((line = reader.readLine()) != null) {
String[] data = line.split(splitBy);
float x1 = Float.parseFloat(data[0]);
float y1 = Float.parseFloat(data[1]);
float x2 = Float.parseFloat(data[2]);
float y2 = Float.parseFloat(data[3]);
Position a = new Position(x1, y1);
Position b = new Position(x2, y2);
float length = (float)Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1-y2, 2));
// All roads are bidirectional.
addPath(a, b, length, vehicle);
addPath(b, a, length, vehicle);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
} |
c831324f-7a69-4eca-be66-fd9f4c17e528 | 0 | public int getRobotState() {
return robotState;
} |
22c5b56a-429f-455b-905a-c592ff3faa00 | 7 | static public Spell getEarthSpell(int i)
{
switch (i)
{
default:
case 0:
return new Earthbending();
case 1:
return new EarthbendingSpike();
case 2:
return new EarthbendingShard();
case 3:
return new EarthbendingShield();
case 4:
return new EarthbendingSand();
case 5:
return new EarthbendingWallOfSand();
case 6:
return new EarthbendingStance();
}
} |
f1c16724-12c2-46d9-a657-3c193db49124 | 9 | private boolean evaluateTcfClause(String clause) {
if (model instanceof MesoModel)
return false;
if (clause == null || clause.equals(""))
return false;
String[] sub = clause.split(REGEX_AND);
Tcf.Parameter[] par = new Tcf.Parameter[sub.length];
String funx, funy;
byte id;
short length;
for (int n = 0; n < sub.length; n++) {
int i = sub[n].indexOf("within");
String str = i == -1 ? sub[n] : sub[n].substring(0, i).trim();
try {
String[] s = str.split(REGEX_SEPARATOR + "+");
funx = s[0];
funy = s[1];
length = Float.valueOf(s[2].trim()).shortValue();
id = Float.valueOf(s[3].trim()).byteValue();
} catch (Exception e) {
out(ScriptEvent.FAILED, "Script error at: " + str + "\n" + e);
return false;
}
if (i >= 0) {
str = sub[n].substring(i).trim();
Matcher matcher = WITHIN_RECTANGLE.matcher(str);
if (matcher.find()) {
Rectangle2D area = getWithinArea(str);
if (area == null)
return false;
par[n] = new Tcf.Parameter(funx, funy, id, length, area);
}
} else {
par[n] = new Tcf.Parameter(funx, funy, id, length, model.boundary);
}
}
((AtomicModel) model).showTCF(par);
return true;
} |
37481b57-a9c8-4d44-8d3f-12d7742935c1 | 2 | public boolean removeLift(int LiftID){
for(int i=0;i<lifts.size();i++){
if(lifts.get(i).getLiftID()==LiftID){
lifts.get(i).delete();
lifts.remove(i);
return true;
}
}
return false;
} |
4c28a560-1183-4789-836c-76e1eef1445b | 3 | @Override
public void paintComponent(Graphics g) {
Graphics2D graphics = (Graphics2D) g;
super.paintComponent(graphics);
/*
* Berechnung der Groesse der Blockelemente. Die Groesse ist abhaengig
* von der Anzahl der Spalten und Zeilen und der jeweils verfuegbaren
* Hoehe und Breite des Panels.
*/
int heightBlockSize = this.getHeight() / Field.rows;
int widthBlockSize = this.getWidth() / Field.columns;
int blockSize = (heightBlockSize * Field.columns > getWidth())
? widthBlockSize : heightBlockSize;
setBlocksize(blockSize);
Point startPoint = new Point(0, 0);
for(int i = 0; i < Field.rows; i++) {
startPoint.x = 0;
for(int j = 0; j < Field.columns; j++) {
BlockElement block = field[currentLayer].getBlockElement(j, i);
graphics.setColor(block.getColor());
graphics.fillRect(startPoint.x, startPoint.y,
blockSize, blockSize);
graphics.setColor(block.getBorderColor());
graphics.drawRect(startPoint.x, startPoint.y,
blockSize, blockSize);
startPoint.x += blockSize;
}
startPoint.y += blockSize;
}
} |
858df2e4-ea5f-4172-adf3-0813d2701ea0 | 9 | private int getNextDir(int[] from,int to,boolean closer,Game.DM measure)
{
int dir=-1;
double min=Integer.MAX_VALUE;
double max=-Integer.MAX_VALUE;
for(int i=0;i<from.length;i++)
{
if(from[i]!=-1)
{
double dist=0;
switch(measure)
{
case PATH: dist=getPathDistance(from[i],to); break;
case EUCLID: dist=getEuclideanDistance(from[i],to); break;
case MANHATTEN: dist=getManhattenDistance(from[i],to); break;
}
if(closer && dist<min)
{
min=dist;
dir=i;
}
if(!closer && dist>max)
{
max=dist;
dir=i;
}
}
}
return dir;
} |
f3594d7d-8d95-40a8-adbc-90b6139a8466 | 7 | public synchronized void setFrame(final CEMILData frame)
{
if (!frame.getDestination().equals(getKey()))
throw new KNXIllegalArgumentException("frame key differs from this key");
if (!max)
ensureCapacity();
else if (!overwrite && size == timestamps.length)
return;
final CEMILData[] c = (CEMILData[]) value;
// notify on first time queue fills up
final boolean notifyListener = max && size == c.length - 1;
resetTimestamp();
c[next] = frame;
timestamps[next] = getTimestamp();
++next;
next %= c.length;
if (size < c.length)
++size;
if (notifyListener)
fireQueueFilled();
} |
7499d1c5-356e-411d-9626-2cd188034654 | 8 | public static List<CategoryNode> buildCategoryByUrl(String url) throws IOException {
System.out.println("Trying to get url: " + url);
Document document;
try {
document = Jsoup.connect(url).get();
} catch(IOException e) {
throw new IOException("Error when get " + url, e);
}
Elements elements = document.select("ul[data-typeid=n]");
List<CategoryNode> nodes = new ArrayList<CategoryNode>();
if(!elements.isEmpty()) {
Element ul = elements.first();
Elements liElements = ul.select("li");
if(!liElements.isEmpty()) {
Iterator<Element> iterator = liElements.iterator();
while(iterator.hasNext()) {
Element li = iterator.next();
if(li.select("strong").size() > 0) {
if(!iterator.hasNext()) {
nodes.add(buildCategoryChain(liElements));
break;
}
while(iterator.hasNext()) {
Element childLi = iterator.next();
String link = childLi.select("a").first().attr("href");
if(!link.startsWith("http")) {
link = AMAZON_HOME + link;
}
nodes.addAll(buildCategoryByUrl(link));
}
}
}
}
}
return nodes;
} |
3484596c-0fd8-42fe-b65c-96582bacc1aa | 9 | public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(new BufferedInputStream(System.in));
PrintWriter cout = new PrintWriter(System.out);
while(sc.hasNext()!=false){
String[] originals = sc.nextLine().split(" ");
if(originals.length==1&&originals[0].equals("0")) break;
if(originals.length==1)continue;
int[] original = new int[originals.length];
for(int i=0;i<originals.length;i++){
original[i]=Integer.parseInt(originals[i]);
}
Arrays.sort(original);
boolean cutonce=false;
boolean[] visited = new boolean[original.length];
int sum=0;
for(int i=0;i<original.length;i++){
sum+=original[i];
}
for (int target =original[original.length-1]+original[0];target <sum/2+1;target++){
int[] result=new int[1];
smallestnumber(original,visited,0,target,result);
if(result[0]==1) {
cutonce=true;
cout.println(target);
break;
}
}
if(cutonce==false) cout.println(sum);
}
cout.flush();
} |
68867186-bbb6-4ee8-af53-f0fae5db0430 | 1 | public boolean PointerMoveListener(int mX, int mY, int mDX, int mDY) {
if(mainLogic.currentState == GameLogic.GameState.PLAYING) {
currentMouseAction.onPointerMove(mX, mY, mDX, mDY);
}
/*
for(long a : selectedWeapons) {
GameActor act = mainLogic.getActor(a);
PhysicsComponent pc = (PhysicsComponent)act.getComponent("PhysicsComponent");
pc.setTarget(mX, mY);
}
*
*/
return false;
} |
010fcce1-760b-4c12-8346-e853401c00dd | 3 | public char skipTo(char to) throws JSONException {
char c;
try {
long startIndex = this.index;
long startCharacter = this.character;
long startLine = this.line;
this.reader.mark(1000000);
do {
c = this.next();
if (c == 0) {
this.reader.reset();
this.index = startIndex;
this.character = startCharacter;
this.line = startLine;
return c;
}
} while (c != to);
} catch (IOException exception) {
throw new JSONException(exception);
}
this.back();
return c;
} |
0c6ed547-f60e-4580-b66a-3c37c12f6bd4 | 3 | public static int getRotatedMapChunkY(int y, int rotation, int x) {
rotation &= 3;
if (rotation == 0) {
return y;
}
if (rotation == 1) {
return 7 - x;
}
if (rotation == 2) {
return 7 - y;
} else {
return x;
}
} |
700b5721-d400-4242-82e2-869e69d037a1 | 5 | public void run() {
ServerSocket s = null;
try{
this.frame.setDB();
s = new ServerSocket(this.PORT);
try {
this.frame.serverOutput.setText("---- Server Avviato Correttamente! ---- \n Server in attesa di richieste...");
while(true) {
Socket socket = s.accept();
try{
new ServerOneClient(socket, this.frame);
} catch(IOException e) {
JOptionPane.showMessageDialog(this.frame, e);
}
}
} catch (IOException e){
JOptionPane.showMessageDialog(this.frame, "Errore nell'attesa di connessioni da parte dei client");
} finally {
try {
s.close();
} catch (IOException e) {
JOptionPane.showMessageDialog(this.frame, "\nErrore! - Impossibile chiudere il Server sulla porta: " + this.PORT);
}
}
} catch (IOException e){
this.frame.serverOutput.setText("Errore! - Impossibile creare il Server sulla porta: " + this.PORT);
}
} |
5da269f2-04a7-4f4e-b181-b0a6dd3eacc6 | 6 | public static String getJavaTypeFor( String type )
{
String tocheck = Util.sanitize( type, false ).toLowerCase();
if ( tocheck.equals( "null" ) )
{
return "null";
}
if ( tocheck.equals( "integer" ) )
{
return "int";
}
if ( tocheck.equals( "real" ) )
{
return "double";
}
if ( tocheck.equals( "text" ) )
{
return "String";
}
if ( tocheck.equals( "string" ) )
{
return "String";
}
if ( tocheck.equals( "autoincrement" ) )
{
return "int";
}
// fallback to whatever it is
return type;
} |
ed5ba37c-fc17-46f6-a846-74c841566187 | 0 | public void setjComboBoxLabo(JComboBox jComboBoxLabo) {
this.jComboBoxLabo = jComboBoxLabo;
} |
89e0414a-c8bb-42eb-a2b5-a675f8c9dca5 | 7 | public String toString() {
StringBuffer sb = new StringBuffer("<class>" + getClass().getName() + "</class>\n");
if (uid != null)
sb.append("<uid>" + uid + "</uid>\n");
sb.append("<width>" + (widthIsRelative ? (widthRatio > 1.0f ? 1 : widthRatio) : getWidth()) + "</width>\n");
sb.append("<height>" + (heightIsRelative ? (heightRatio > 1.0f ? 1 : heightRatio) : getHeight())
+ "</height>\n");
sb.append("<title>" + encodeText() + "</title>\n");
if (isOpaque()) {
sb.append("<bgcolor>" + Integer.toString(getBackground().getRGB(), 16) + "</bgcolor>\n");
}
else {
sb.append("<opaque>false</opaque>\n");
}
if (!getBorderType().equals(BorderManager.BORDER_TYPE[0]))
sb.append("<border>" + getBorderType() + "</border>\n");
return sb.toString();
} |
9332cb64-d1c9-4a6a-879e-e30f53770532 | 9 | private void addNewBook(){
int choice;
boolean quit;
quit = false;
try
{
con.setAutoCommit(false);
while(!quit)
{
System.out.print("\n\nPlease choose one of the following: \n");
System.out.print("1. Add Standard\n");
System.out.print("2. Add Additional Author\n");
System.out.print("3. Add Additional Subject\n");
System.out.print("4. Add Additional Copy\n");
System.out.print("5. Quit");
choice = Integer.parseInt(in.readLine());
System.out.println(" ");
switch(choice)
{
case 1: addStandard(); break;
case 2: moreAuthor(); break;
case 3: moreSubject(); break;
case 4: moreCopy(); break;
case 5: quit = true;
}
}
con.close();
selectLibrarian();
}
catch (IOException e)
{
System.out.println("IOException!");
try
{
con.close();
System.exit(-1);
}
catch (SQLException ex)
{
System.out.println("Message: " + ex.getMessage());
}
}
catch (SQLException ex)
{
System.out.println("Message: " + ex.getMessage());
}
} |
f1967b4f-f1f9-427d-b212-dcf3b862aa2b | 8 | private static String suit(Card card) {
switch(card.getSuit()) {
case HEARTS:
return !UNICODE ? "H" : "\u2661"; // 2665 on windows
case DIAMONDS:
return !UNICODE ? "D" : "\u2662"; // 2666 on windows
case SPADES:
return !UNICODE ? "S" : "\u2660";
case CLUBS:
return !UNICODE ? "C" : "\u2663";
default:
return null;
}
} |
4492ddff-83c8-41a1-8bec-880ca97e5ce8 | 5 | public JComboBoxUnit() {
super();
final ListCellRenderer r = getRenderer();
setRenderer(new ListCellRenderer() {
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus) {
Component c;
if(disableIndexSet.contains(index)) {
c = r.getListCellRendererComponent(list,value,index,false,false);
c.setEnabled(false);
}else{
c = r.getListCellRendererComponent(list,value,index,isSelected,cellHasFocus);
c.setEnabled(true);
}
return c;
}
});
Action up = new AbstractAction() {
public void actionPerformed(ActionEvent e) {
int si = getSelectedIndex();
for(int i = si-1;i >= 0;i--) {
if(!disableIndexSet.contains(i)) {
setSelectedIndex(i);
break;
}
}
}
};
Action down = new AbstractAction() {
public void actionPerformed(ActionEvent e) {
int si = getSelectedIndex();
for(int i = si+1;i < getModel().getSize();i++) {
if(!disableIndexSet.contains(i)) {
setSelectedIndex(i);
break;
}
}
}
};
ActionMap am = getActionMap();
am.put("selectPrevious3", up);
am.put("selectNext3", down);
InputMap im = getInputMap();
im.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), "selectPrevious3");
im.put(KeyStroke.getKeyStroke(KeyEvent.VK_KP_UP, 0), "selectPrevious3");
im.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), "selectNext3");
im.put(KeyStroke.getKeyStroke(KeyEvent.VK_KP_DOWN, 0), "selectNext3");
} |
7cb218a5-71cf-4976-8ad1-87f92fb34ed4 | 9 | public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
StringBuilder out = new StringBuilder();
String line;
Queue<Character> q = new LinkedList<>();
boolean hyphen = false;
while ((line = in.readLine()) != null) {
if ((line = line.trim()).equals("#"))
break;
char[] l = line.trim().toCharArray();
for (int i = 0; i < l.length; i++) {
if (Character.isLetter(l[i]))
q.add(l[i]);
else if (l[i] == ' ') {
while (!q.isEmpty())
out.append(q.poll());
if(hyphen)
out.append('\n');
hyphen = false;
out.append(' ');
}
}
if (l[l.length - 1] != '-')
while (!q.isEmpty())
out.append(q.poll());
else
hyphen = true;
out.append('\n');
}
System.out.print(out);
} |
55891763-750f-4ea3-b8ea-890364d36c46 | 4 | private Type mergeClasses(Type type) throws NotFoundException {
CtClass superClass = findCommonSuperClass(this.clazz, type.clazz);
// If its Object, then try and find a common interface(s)
if (superClass.getSuperclass() == null) {
Map interfaces = findCommonInterfaces(type);
if (interfaces.size() == 1)
return new Type((CtClass) interfaces.values().iterator().next());
if (interfaces.size() > 1)
return new MultiType(interfaces);
// Only Object is in common
return new Type(superClass);
}
// Check for a common interface that is not on the found supertype
Map commonDeclared = findExclusiveDeclaredInterfaces(type, superClass);
if (commonDeclared.size() > 0) {
return new MultiType(commonDeclared, new Type(superClass));
}
return new Type(superClass);
} |
02ff1336-98d7-41d2-adbb-1f70ceb195e2 | 4 | public boolean tarkistaSarakkeet(int kuka) {
int vierekkaiset = 0;
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
if (poyta[j][i] == kuka) {
vierekkaiset++;
}
}
if (vierekkaiset == 3) {
return true;
} else {
vierekkaiset = 0;
}
}
return false;
} |
424cbafd-dce0-427e-ab74-7efec0f76fad | 4 | private boolean fileIsVideo(String string) {
if(string.endsWith(".mov") || string.endsWith(".MOV") || string.endsWith(".mp4") || string.endsWith(".MP4"))
return true;
return false;
} |
01ee3b9e-57f3-48c1-b8b5-76c85c6dd14a | 9 | public int get_END_IF(int INDEX, String code)
{
log.log(4, log_key, "call get_END_IF, INDEX = ", new Integer(INDEX).toString(), "\n");
for(;;INDEX++) {
if ( (code.charAt(INDEX) == 'E') &&
(code.charAt(INDEX + 1) == 'N') &&
(code.charAt(INDEX + 2) == 'D') &&
(code.charAt(INDEX + 3) == '_') &&
(code.charAt(INDEX + 4) == 'I') &&
(code.charAt(INDEX + 5) == 'F') )
{
log.log(4, log_key, "return get_END_IF, INDEX = ", new Integer(INDEX).toString(), "\n");
return INDEX;
}
else if ( (code.charAt(INDEX) == 'I') &&
(code.charAt(INDEX + 1) == 'F') )
{
log.log(4, log_key, "recursive call get_END_IF, INDEX = ", new Integer(INDEX).toString(), "\n");
INDEX = get_END_IF(INDEX, code) + 5;
continue;
}
}
} |
514f8a3c-a3a2-4211-aba7-0c7e32f1e5df | 3 | @Override
protected boolean check() {
return (method.getParameterTypes()[0] == Updates.class && (method
.getParameterTypes()[1] == String.class || (method
.getParameterTypes()[1] == String[].class && method
.getParameterTypes()[2] == String.class)));
} |
902c80b6-1db4-45b1-a845-1b505e518def | 7 | public static BPInt from(byte[] bytes) {
// note - all negative numbers are represented by 8 bytes.
int size = bytes.length;
boolean highestBitIsSet = ((0x80 & bytes[0]) == 128);
if (size == 1) {
return new BPInt(0xff & bytes[0]);
} else if (size == 2) {
return new BPInt(((0xff & bytes[0]) << 8) | (0xff & bytes[1]));
} else if (size == 4) {
if (highestBitIsSet) {
// in this case, we have a number between 2^31 and 2^32 - 1. This won't fit in an int, so we have to force it to be a long
// TODO - should we return it as a number of type Int, but marked as isUnsigned, meaning that
// clients should use the long value instead? That might be more consistent.
return new BPInt(((0xff & (long)bytes[0]) << 24) | ((0xff & (long)bytes[1]) << 16) | ((0xff & (long)bytes[2]) << 8) | (0xff & (long)bytes[3]), false);
} else {
return new BPInt(((0xff & bytes[0]) << 24) | ((0xff & bytes[1]) << 16) | ((0xff & bytes[2]) << 8) | (0xff & bytes[3]));
}
} else if (size == 8) {
if (highestBitIsSet) {
long msb = (long) (((0xff & (long)~bytes[0]) << 24) | ((0xff & (long)~bytes[1]) << 16) | ((0xff & (long)~bytes[2]) << 8) | (0xff & (long)~bytes[3]));
long lsb = (long) (((0xff & (long)~bytes[4]) << 24) | ((0xff & (long)~bytes[5]) << 16) | ((0xff & (long)~bytes[6]) << 8) | (0xff & (long)~bytes[7]));
long value = (-((msb << 32) + lsb))-1;
return (value < Integer.MIN_VALUE) ? new BPInt(value, false) : new BPInt((int)value);
} else {
long msb = (long) (((0xff & (long)bytes[0]) << 24) | ((0xff & (long)bytes[1]) << 16) | ((0xff & (long)bytes[2]) << 8) | (0xff & (long)bytes[3]));
long lsb = (long) (((0xff & (long)bytes[4]) << 24) | ((0xff & (long)bytes[5]) << 16) | ((0xff & (long)bytes[6]) << 8) | (0xff & (long)bytes[7]));
return new BPInt((msb << 32) + lsb, false);
}
} else {
// size = 16 - this is used to represent unsigned ints between 2^63 and 2^64 - 1 so they
// can be distinguished from signed ints between -(2^63) and 0.
long msb = (long) (((0xff & (long)bytes[8]) << 24) | ((0xff & (long)bytes[9]) << 16) | ((0xff & (long)bytes[10]) << 8) | (0xff & (long)bytes[11]));
long lsb = (long) (((0xff & (long)bytes[12]) << 24) | ((0xff & (long)bytes[13]) << 16) | ((0xff & (long)bytes[14]) << 8) | (0xff & (long)bytes[15]));
return new BPInt((msb << 32) + lsb, true);
}
} |
beb6a440-faa7-4da4-b3c4-584cedd4a64e | 0 | public List<Blog> getBlogs(){
return blogModelBS.getBlogs();
} |
8371276d-17d8-4461-8c41-774fb0aea8a5 | 1 | public static boolean isNegativeSentiment ( String str ) {
if ( negativeHashMap.containsKey(str) ) return true;
else return false;
} |
10fbb753-4b54-4b3c-a3ad-670612103bfb | 1 | private void nextToken()
{
try
{
current = scanner.next();
}
catch (IOException e)
{
}
} |
27975403-0de0-4b2a-85a1-7b6c93004cb9 | 1 | public void visit_dup_x2(final Instruction inst) {
// Top value on stack must be category 1.
final Set top1 = atDepth(0);
checkCategory(top1, 1);
final Set top2 = atDepth(1);
final int category = checkCategory(top2);
if (category == 1) {
final Set top3 = atDepth(2);
checkCategory(top3, 1);
// Form 1: Dup top value and put three down
currStack.add(currStack.size() - 3, new HashSet(top1));
} else {
// Form 2: Dup top value and put two down
currStack.add(currStack.size() - 2, new HashSet(top1));
}
} |
d504cbf8-2ab7-4c5c-9bfb-708595cc451c | 9 | static boolean isSameType(Type t1, Type t2, Types types) {
if (t1 == null) { return t2 == null; }
if (t2 == null) { return false; }
if (isInt(t1) && isInt(t2)) { return true; }
if (t1.tag == UNINITIALIZED_THIS) {
return t2.tag == UNINITIALIZED_THIS;
} else if (t1.tag == UNINITIALIZED_OBJECT) {
if (t2.tag == UNINITIALIZED_OBJECT) {
return ((UninitializedType)t1).offset == ((UninitializedType)t2).offset;
} else {
return false;
}
} else if (t2.tag == UNINITIALIZED_THIS || t2.tag == UNINITIALIZED_OBJECT) {
return false;
}
return types.isSameType(t1, t2);
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.