text stringlengths 14 410k | label int32 0 9 |
|---|---|
private int segundos() {
return hora * 3600 + minuto * 60 + segundo;
} | 0 |
public static List<Producto> buscar(Integer codigo, String nombre, String estado){
List<Producto> encontrados=new ArrayList<Producto>();
for(Producto p : productos){
if(p.getCodigo().equals(codigo) || (p.getNombre().contains(nombre) && !nombre.isEmpty()) || (p.getEstado().equals(estado) && !estado.equals("TOD... | 6 |
public byte[] getImage(String exeName) {
try {
Process p = Runtime.getRuntime().exec("./res/getPrograms.bat " + exeName);
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
int count = 0;
while(true) {
line = input.readLine();
... | 6 |
public static void main(String[] args) {
if (args.length != 1) {
System.err.println("usage: java TestOneSimulation <test filename>");
System.exit(0);
}
boolean voters[] = Utility.setupVoters(args[0]);
int steps = Opinion.doOneSimulation(voters);
if (steps != Utility.numSteps) {
System.out.printf("... | 7 |
@Override
protected void inspectContents(File file, String contents) {
if (checkType.equals(XMLChecker.VALID)) {
System.out.println(" START VALIDATION FOR FILE: " + file.getPath());
doParse(contents);
System.out.println(" END VALIDATION");
} else if (checkType.equals(XMLChecker.WELL_FORMED)) {
System... | 2 |
@Override
public boolean equals( Object obj ) {
if( obj == this ) {
return true;
}
if( obj == null || obj.getClass() != getClass() ) {
return false;
}
ConnectionLabelConfiguration that = (ConnectionLabelConfiguration) obj;
return that.id.equals( id );
} | 3 |
public static String HuffmanCode(String s)
{
if (s.length() <= 1)
return "0";
//construct the map
Map<Character,Integer> m = new HashMap<Character,Integer>();
for (int i = 0; i < s.length(); ++i)
{
if (!m.containsKey(s.charAt(i)))
{
... | 8 |
public String[][] insertAndGetNewFields(String query) throws SQLException {
checkConnection();
if(conn != null) {
Statement stmt;
try {
stmt = conn.createStatement();
stmt.executeUpdate(query, Statement.RETURN_GENERATED_KEYS);
ResultSet resSt = stmt.getGeneratedKeys();
ArrayList<String[]> al =... | 4 |
@Test
public void esteenTarkkaSijainti() {
ArrayList<String> rivit = new ArrayList();
rivit.add("E 100 100 200 200");
Este e = new Este(100, 100 ,200, 200);
Piste p = new Piste();
TasonLuonti tl = new TasonLuonti(rivit);
Taso ta = tl.getTaso();
assertTrue("Est... | 0 |
public static String replaceAll(String str, String thisStr, String withThisStr)
{
if ((str == null) || (thisStr == null) || (withThisStr == null) || (str.length() == 0) || (thisStr.length() == 0))
return str;
for (int i = str.length() - 1; i >= 0; i--)
{
if (str.charAt(i) == thisStr.charAt(0))
{
if ... | 8 |
public boolean isSitting() {
if (rend != null) {
return (rend.hasImage("body/sitting") == true);
} else return false;
} | 1 |
protected void end() {} | 0 |
@Override
public JSONObject main(Map<String, String> params, Session session)
throws Exception {
JSONObject rtn = new JSONObject();
long uid = session.getActiveUserId();
// if no active user
if(uid==0) {
rtn.put("rtnCode", this.getRtnCode(201));
return rtn;
}
User activeUser = User.findById(uid... | 1 |
private void initComponents() {
addWindowListener(new WindowAdapter() {
@Override
public void windowClosed(WindowEvent e) {
if (!startPressed) {
if (script != null) {
script.ctx.controller.stop();
}
}
}
});
for (String category : script.itemCategoriser.getCategorys()) {
//tab0... | 4 |
public BoardFileBean getFileName(int idx) throws Exception{
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
BoardFileBean fileBean = null;
String sql = "";
String filename = "";
String fileTmp = "";
try{
conn = getConnection();
sql = "select * from boardfile where idx=... | 9 |
public static void main(String[] args) throws IOException {
boolean quit = false; // main loop bool
System.out.println("Welcome to C. Yotov's RSA implementation!");
// If there is a problem with the menu, use the commented code below
/*
final long startTimeKey = System.currentTimeMillis();
KeyGen.keyCreati... | 5 |
public String getAccountTypeString()
{
String toReturn = null;
if(accountType == Type.SYSTEMADMIN) {
toReturn = "System Administrator";
} else if(accountType == Type.ACADEMICADMIN) {
toReturn = "Academic Administrator";
} else if(accountType == Type.ASSISTANTA... | 5 |
@SuppressWarnings("static-access")
public LinkedList<Human> readDatabase() {
String noteType;
TypeSwitch typeSwitcher = null;
String line;
try {
while ((line = reader.readLine()) != null) { // Читаем до конца
// файла
while (!line.equals("-")) // Читаем до маркера разделителя
{
... | 7 |
public byte[] compress(byte[] buf, int start, int[] len){
stream.next_in=buf;
stream.next_in_index=start;
stream.avail_in=len[0]-start;
int status;
int outputlen=start;
byte[] outputbuf=buf;
int tmp=0;
do{
stream.next_out=tmpbuf;
stream.next_out_index=0;
stream.avail_o... | 3 |
@RequestMapping(value = "/user/{userName}")
public String getMainPage(Model model, @PathVariable String userName) {
User user = userService.getUserName(userName);
DAOExampleObject daoExampleObject = userService.getAttackFromDao();
if (user == null) {
return "404";
}
... | 3 |
public boolean isServerTrusted(X509Certificate[] cert)
{
try
{
cert[0].checkValidity();
return true;
}
catch (CertificateExpiredException e)
{
return false;
}
catch (CertificateNotYetValidException e)
{
r... | 2 |
public static TreeMap<String, Integer> getItemID(ArrayList<String> id) {
InputSource data;
StringBuilder idList = new StringBuilder();
if (id.size() == 0 || id.size() > maxAPIRequest) {
return null;
}
for (String s : id) {
if (idList.length() == 0) {
idList.append(s);
} else {
idList.append... | 4 |
public void send(Packet packet) {
System.out.println("[Server] Sending to " + getRemoteAddress() + ": " + packet);
try {
socket.write(PacketCodecs.SERVER_CLIENT.write(packet));
} catch (IOException e) {
e.printStackTrace();
}
} | 1 |
@Override
public String describeParameters(final Map<String, String> props) {
final String task =
props.get(DeployerConstants.SETTINGS_TASK);
final String args =
props.get(DeployerConstants.SETTINGS_ARGUMENTS);
final String ant_target =
props.get(Deploy... | 6 |
@Override
public void report() {
final List<String> busiestActors = new ArrayList<>();
int highestCount = 0;
for (final Map.Entry<String, Integer> actorYearToMovieCountEntry : actorYearToMovieCount.entrySet())
if (actorYearToMovieCountEntry.getValue() > highestCount) {
... | 3 |
public void removeADay(){
if(!timer.isRunning()){
if(buttonArray.size() > 2){
if(JOptionPane.showConfirmDialog(Main.mainPanel, "Do you want to remove a day?",
"Remove a day", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION){
if(Main.selectedDay >= buttonArray.size()-1){
if(Main.isDay){
... | 5 |
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException {
HttpSession session = ((HttpServletRequest) request).getSession();
if (session.getAttribute("profile") == null) {
request.getRequestDispatche... | 5 |
public static void modstat(String input)
{
String[] split = input.split(" ", 3);
if(split[1].equalsIgnoreCase("health"))
{
Parasite.thePlayer.modifyHealth(Integer.parseInt(split[2]));
}
else if(split[1].equalsIgnoreCase("sanity"))
{
... | 5 |
private MigratableProcess getProcess(long id) {
Iterator<MigratableProcess> it = processes.iterator();
while (it.hasNext()) {
MigratableProcess process = it.next();
if (process.getId() == id)
return process;
}
return null;
} | 2 |
static double[] toDoubleArray(float[] arr) {
if (arr == null) return null;
int n = arr.length;
double[] ret = new double[n];
for (int i = 0; i < n; i++) {
ret[i] = (double)arr[i];
}
return ret;
} | 2 |
@Override
public void mouseMove(MouseEvent e) {
if(this.getMouseListener() != null)
{
this.getMouseListener().MouseMove(this, e);
}
} | 1 |
public void deposit(BigInteger amount) throws IllegalArgumentException {
if ( (amount == null) || (amount.compareTo(BigInteger.ZERO) <= 0) )
throw new IllegalArgumentException();
setBalance(this.getBalance().add(amount));
} | 2 |
private StringBuffer internalReadStringBuffer(StringBuffer buf, int length) throws IOException {
if ((byteBuffer == null) || (byteBuffer.length < length))
byteBuffer = new byte[length];
is.readFully(byteBuffer, 0, length);
readUTF8Chars(buf, byteBuffer, 0, length);
return buf... | 2 |
public static Vector3 nearestPointOfIntersectionCylinder(Vector3 rayPosition,
Vector3 rayDirection, Vector3 u, Vector3 v, double radius) {
double uvLengthSquared = (v.subtract(u)).lengthSquared();
double a = rayDirection.lengthSquared() * uvLengthSquared - rayDirection.dotProduct(v.subtract(u)) * rayDirection.do... | 7 |
public String getDescription()
{
return description;
} | 0 |
private int donneeSuivante( String chaine, int i ) {
while (chaine.charAt(i) == this.separateur)
i++;
return i;
} | 1 |
@Override
public Vector3d getForceAt(Vector3d position, Matrix3d rotation,
Vector3d point) {
Vector3d localPoint = new Vector3d(point);
localPoint.sub(position);
if (localPoint.lengthSquared() > outerRadius * outerRadius) {
return new Vector3d(0, 0, 0);
}
Vector3d force = new Vector3d(localPoint);
... | 2 |
protected int addPoint(Vector3d p) {
Vector3d q;
int index = 0;
boolean found = false;
for (int i = 0; i < points.size(); i++) {
q = points.elementAt(i);
if ((q.x == p.x) && (q.y == p.y) && (q.z == p.z)) {
index = i;
found = true;
... | 5 |
public List<Integer> getTeams(URL url) {
Document doc;
Tidy tidy = new Tidy();
List<Integer> retVal = new ArrayList<Integer>();
try {
doc = tidy.parseDOM(url.openStream(), null);
XPath xpath = XPathFactory.newInstance().newXPath();
XPathExpression expr = xpath.compile("//tr[@bgcolor = '#FFFFFF']/... | 3 |
public float getX() {
return x;
} | 0 |
public Wave43(){
super();
MobBuilder m = super.mobBuilder;
for(int i = 0; i < 2750; i++){
if(i % 8 == 0)
add(m.buildMob(MobID.ONIX));
else if(i % 7 == 0)
add(m.buildMob(MobID.MACHOP));
else if(i % 6 == 0)
add(m.buildMob(MobID.GRAVELER));
else if(i % 5 == 0)
add(m.buildMob(MobID.MAROWAK... | 5 |
public void addAvailablePositionForPawn(int row, int col, Board theBoard,ArrayList<Position> validMoves, boolean mustCapture) {
Position newPosition = new Position(row, col);
if(newPosition.isOnBoard() &&
((mustCapture && theBoard.isPieceAtPosition(newPosition) && !theBoard.getPiece(newPosition).hasSameColor... | 6 |
public static void main(String[] args) {
ParcelInitialization p = new ParcelInitialization();
Destination d = p.destination("Tasmania");
} | 0 |
public static String timeIntervalToString(long millis) {
StringBuffer sb = new StringBuffer();
if (millis < 10 * Constants.SECOND) {
sb.append(millis);
sb.append("ms");
} else {
boolean force = false;
String stop = null;
for (int ix = 0... | 7 |
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
TabbedPanel tabbedPanel = TabbedUtils.getParentTabbedPanel(c);
if (tabbedPanel != null) {
Direction d = tabbedPanel.getProperties().getTabAreaOrientation();
g.setColor(color.getColor(c));
if (d == Directi... | 8 |
public boolean _setSpriteImage(URL spriteSourceImageURL)
{
if(spriteSourceImageURL != null)
{
sprite._setSpriteImage(spriteSourceImageURL);
return true;
}
else
{
return false; // Couldn't update sprite. Probably invalid sprite given.
}
} | 1 |
public void setRemainingFieldToMinSim(double min) {
for (int i = 0; i < fieldSize; i++) {
for (int j = 0; j < fieldSize; j++) {
if (idealDistance[i][j] == 0 && i != j) { //not yet set
idealDistance[i][j] = getDistance(min); //set to parameter
idealDistance[j][i] = idealDistance[i][j];
forceRat... | 4 |
public ParticleSystem(float deltaT, boolean randomStart) {
this.deltaT = deltaT;
if (!randomStart) {
for (int i = 3; i < 8; i++) {
for (int j = 15; j < 250; j++) {
for (int k = 3; k < 6; k++) {
particles.add(new Particle(new Vector3(i, j, k), 1f));
}
}
}
} else {
for (int i = 0; i... | 5 |
public void setWrap(String d, boolean e){
int s; if(e){s = 1;}else{s = 0;}
if(d == "X"){xwrap = e;bpol[2] = s; bpol[6] = s;}
if(d == "Y"){ywrap = e;bpol[0] = s; bpol[4] = s;}
if(xwrap && ywrap){bpol[1] = 1; bpol[3] = 1; bpol[5] = 1; bpol[7] = 1;}
else{bpol[1] = 0; bpol[3] = 0; bpol[5] = 0; bpol... | 5 |
@Override
public boolean isValidRoute(String route) {
// TODO Auto-generated method stub
if (route == null || route.equals("")) {
return false;
}
String[] stations = route.split(DELIMITER_BETWEEN_STATIONS);
if (stations == null || stations.length == 0) {
return false;
}
// step1, validate all sta... | 9 |
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
System.out.println("Enter computer ID:");
id = Integer.parseInt(in.nextLine());
System.out.println("Enter port address for this computer:");
port = Integer.parseInt(in.nextLine());
server s = new server();
stateThread st = new... | 7 |
public static void main(String[] args) {
int age = 15;
switch(age){
case 14:
System.out.println("You're in 9th grade.");
break;
case 15:
System.out.println("You're in 10th grade.");
break;
case 16:
System.out.println("You're in 11th grade.");
break;
default:
System.out.println("A... | 3 |
public static boolean logReceivedLine(boolean directionIN, long threadID, String agentRegistrationID, String sender, String recipient, String senderIP, String recipientIP, String line)
{
try
{
if (!isLoggingEnabled)
{
return false;
}
if (alLoggingAgents == null)
{
... | 8 |
private void addToCellGroup(ArrayList<AgentsGroup> cellGroups, BaseAgent agent) {
AgentsGroup agentGroup;
BaseAgent groupRepresentative;
BaseInformation agentInformation, groupRepresentativeInformation;
ArrayList<HumanAgent> humans;
agentGroup = null;
agent... | 7 |
public int bestAction()
{
int selected = -1;
double bestValue = -Double.MAX_VALUE;
for (int i=0; i<children.length; i++) {
if(children[i] != null) {
double childValue = children[i].totValue / (children[i].nVisits + this.epsilon);
childValue = Uti... | 4 |
public void populateRatingMap() {
Connection connection = new DbConnection().getConnection();
ResultSet resultSet = null;
Statement statement = null;
try {
statement = connection.createStatement();
resultSet = statement.executeQuery(SELECT_ALL_RATINGS);
while (resultSet.next()) {
int ratingId = re... | 6 |
public String[] nextStrings(int n) throws IOException {
String[] res = new String[n];
for (int i = 0; i < n; ++i) {
res[i] = next();
}
return res;
} | 1 |
private String justify(ArrayList<String> line, int wordLength, int L, boolean lastLine) {
int empties = line.size() - 1;
if (empties == 0 || lastLine) {
String result = "";
for (int i = 0; i < line.size(); i++) {
result += line.get(i);
if (i != line.size() - 1) {
result += " ";
}
}
for ... | 9 |
public void update(int xPos, int yPos, boolean isDown) {
if (contains(xPos, yPos)) {
if (isDown && !oldIsDown)
event.run();
if (isSelected < gradations - 1) isSelected++;
} else if (isSelected > 0) isSelected--;
oldIsDown = isDown;
} | 5 |
public void DoAction()
{
Scanner sc = new Scanner(System.in);
String action;
boolean valid = false;
while(!valid)
{
action = Input.getStringInput(sc, "Action: ");
if(action.equalsIgnoreCase("EXPLORE"))
{
e.Trave... | 7 |
public int[] twoSum(int[] numbers, int target) {
if (numbers == null || numbers.length == 0)
return null;
int[] result = new int[2];
//Put all numbers in a map with indexes as values
Map<Integer, Integer> allNumbers = new HashMap<Integer, Integer>();
for (int i=0;... | 8 |
private void handleGameInput() {
while (Keyboard.next()) {
if (Keyboard.getEventKeyState()) {
if (Keyboard.getEventKey() == KeyPress.PAUSE.getKeyID()) {
GameState.pauseUnpause();
}
}
}
boolean sprinting = KeyPress.SPRINT.isDown();
if (KeyPress.FORWARD.isDown()) {
model.getPlayer().move... | 7 |
protected void rehash() {
capacity *= 2;
Entry<K, V>[] old = bucket;
bucket = (Entry<K, V>[]) new Entry[capacity];
setRandomScaleAndShift();// calling hash function index will be
// different
for (int i = 0; i < old.length; i++) {
Entry<K, V> e = old[i];
if ((e != null) && (e != available)) {
... | 3 |
public void raiseUncharted() {
Tile tile;
for (int i = 0; i < uncharted.length; i++) {
for (int j = 0; j < uncharted[0].length; j++) {
tile = new Tile(i, j);
if (((uncharted[i][j] + 5) < 30 && uncharted[i][j] > -1 && game.isVisible(tile))) {
uncharted[i][j] += 5;
}
}
}
} | 5 |
public static List<Word> blur(int distance, String rawWord) {
List<Word> returnList = new ArrayList<Word>(100000);
String word = rawWord.toLowerCase().trim();
Set<Word> returnSet = new HashSet<Word>(100000);
for (int i=1; i<= distance; i++) {
List<String> alphabet = getAlph... | 3 |
public Match getMatch(int matchNumber) {
for (Match match : matches) {
if (match.getMatchNumber() == matchNumber) {
return match;
}
}
return null;
} | 2 |
private final void parseStartTag() throws IOException {
read(); // <
mName = readName();
mStack.add(mName);
while (true) {
String attrName;
int ch;
int pos;
skip();
ch = mPeek0;
if (ch == '/') {
mIsEmptyElementTag = true;
read();
skip();
read('>');
break;
}
if (ch =... | 8 |
public void init(){
// 读取配置文件,根据配置文件创建配置信息
Properties props = new Properties();
try {
InputStream fileInput = new FileInputStream(this.getClass().getResource("/").toString().replace("file:/", "") + CONFIG_FILE );
// 加载配置文件
props.load(fileInput);
} catch (FileNotFoundException e) {
e.printStackTrace... | 4 |
public void setVal(int i)
{
mySlider.setValue(i);
refresh();
// getRootPane().repaint();
} | 0 |
public SubGrid (Grid<E> _backing, int _x0, int _y0, int _w, int _h) {
x0 = _x0; y0 = _y0; w = _w; h = _h;
backing = _backing;
if (x0 < 0
|| y0 < 0
|| x0 + w >= backing.width()
|| y0 + h >= backing.height())
throw new ArrayIndexOutOfBoundsException();
} | 4 |
public static void main(String st[]) throws IOException
{
/*FileReader fr = new FileReader("http://kural.muthu.org/kural.php");*/
URL u = new URL ("http://kural.muthu.org/kural.php?pid=2");
// URL u = new URL ("http://cinekadal.blogspot.in/");
BufferedReader br = new BufferedReader(new InputStreamReader(u... | 1 |
protected void addInstance(Element parent, Instance inst) {
Element node;
Element value;
Element child;
boolean sparse;
int i;
int n;
int index;
node = m_Document.createElement(TAG_INSTANCE);
parent.appendChild(node);
// sparse?
sparse = (inst instanceof S... | 8 |
private void consolodateLongs()
{
for(int i=0;i<longArray.length-1;i++)
{
if(((longArray[i]&NEXT_FLAGL)==0)
&&(longArray[i]+1==(longArray[i+1]&LONG_BITS)))
{
if((longArray[i+1]&NEXT_FLAGL)>0)
{
if((i>0)&&((longArray[i-1]&NEXT_FLAGL)>0))
{
shrinkLongArray(i,2);
return;
}
... | 8 |
private void paintExternalForce(Graphics2D g) {
g.setColor(((MDView) model.getView()).contrastBackground());
double place1 = x + width;
double place2 = place1 + 8.0;
double place3 = y + height;
double place4 = place3 + 8.0;
int nx = (int) (width / delta);
int ny = (int) (height / delta);
int i;
doub... | 9 |
public boolean check_read() {
if (!in_active || (state != State.active && state != State.pending))
return false;
// Check if there's an item in the pipe.
if (!inpipe.check_read ()) {
in_active = false;
return false;
}
// If the next item in... | 5 |
public String getStatus() {
return status;
} | 0 |
public void removeActionListener(ActionListener listener) {
if (mActionListeners != null) {
mActionListeners.remove(listener);
if (mActionListeners.isEmpty()) {
mActionListeners = null;
}
}
} | 2 |
public void save(Course[][] courses, String fileName)
{
try
{
FileWriter output = new FileWriter(fileName);
BufferedWriter out = new BufferedWriter(output);
for (int x = 0; x < courses.length; x++)
{
for (int y = 0; y < courses[x].length; y++)
{
if (c... | 4 |
public User getUser(String email)
{
Connection connection = null;
User user = new User();
String query = null;
PreparedStatement statement = null;
try
{
connection = dataSource.getConnection();
query = "SELECT username, bio FROM users WHERE email = ?;";
statement = (PreparedStatement)con... | 3 |
@Override
public void collideWith(Element e) {
if (isActive()) {
if (e instanceof Destroyable)
getGrid().permanentlyRemoveElement(e);
if (e instanceof Player) {
Player player = (Player) e;
forceFieldConnection.incrementPlayerTrappedCount(player);
}
}
} | 3 |
public void loadSoundpackList() {
logger.debug("Loading all installed Soundpacks");
this.soundpacks.clear();
if (SOUNDPACKFOLDER.exists()) {
for (File soundpackFolder : SOUNDPACKFOLDER.listFiles()) {
if (soundpackFolder.isDirectory()) {
soundpacks.add(soundpackFolder);
logger.debug(soundpackFolde... | 3 |
@Override
public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel)
{
MOB target=this.getTarget(mob,commands,givenTarget);
if(target==null)
return false;
if(target.fetchEffect(ID())!=null)
{
mob.tell(L("You already healed by ice."));
return false;
}
i... | 9 |
@Override
public CheckResultMessage checkFileName() {
return errorNameFormat();
} | 0 |
public void destroyProgress(String missileId, String type) {
Iterator<String> keySetIterator = map.keySet().iterator();
Iterator<String> destructorsSetIterator = destructors.keySet()
.iterator();
if (type == "missile") {
while (keySetIterator.hasNext()) {
String key = keySetIterator.next();
progre... | 9 |
public Object nextContent() throws JSONException {
char c;
StringBuffer sb;
do {
c = next();
} while (Character.isWhitespace(c));
if (c == 0) {
return null;
}
if (c == '<') {
return XML.LT;
}
sb = new Str... | 7 |
public BranchLeaderListResponse(
final Boolean success, final String errorMessage, final List<BranchLeader> branchLeaderList
) {
super(success, errorMessage);
this.branchLeaderList = branchLeaderList;
} | 0 |
public CourseRec getClassByLongNameAndUni(String name, String uni,
Source source) {
for (CourseRec cr : submodel[source.ordinal()].courses.values()) {
if (name.equals(cr.getName())) {
for (DescRec dr : cr.getUniversities())
if (uni.equals(dr.getId()))
return cr;
}
}
return null;
} | 4 |
public final boolean hasOriginalAccelerator() {
KeyStroke ks = getAccelerator();
return ks == null ? mOriginalAccelerator == null : ks.equals(mOriginalAccelerator);
} | 1 |
public static void printMinCutsToPartitionNCube(char[] str) {
int len = str.length, j=0;
int[][] c = new int[len][len]; //min cuts required to partition substring str[i...j]
boolean[][] p = new boolean[len][len]; //p[i][j] is true if str[i...j] is palindrome.
//c[i][j] is 0 if p[i][j] is true.
for (int i =... | 7 |
public static void defaultCmdLineOptionHandler(CmdLineOption option, Stella_Object value) {
{ String property = option.configurationProperty;
Stella_Object defaultvalue = option.defaultValue;
if (property == null) {
property = "";
{ StringWrapper key = null;
Cons iter000 = opt... | 9 |
int evaluateState(Checker[][] state) {
int whiteNumber = 0;
int blackNumber = 0;
for (int row = 0; row < 8; row++) {
for (int col = 0; col < 4; col++) {
if (state[row][col] != null) {
if (state[row][col].getColor() == 1) {
w... | 9 |
public Result bfs()
{
long startTime = System.currentTimeMillis();
Queue<Node> queue = new ArrayDeque<Node>();
Set<Node> set = new HashSet<Node>();
int nodesProcessed = 0;
queue.add(initial);
set.add(initial);
while(!queue.isEmpty())
{
Node temp = queue.poll();
nodesProcessed++;
if(te... | 7 |
public static ArrayList<FriendRequestMessage> getMessagesByUserID(int userID) {
ArrayList<FriendRequestMessage> FriendRequestMessageQueue = new ArrayList<FriendRequestMessage>();
try {
String statement = new String("SELECT * FROM " + DBTable +" WHERE uid2 = ?");
PreparedStatement stmt = DBConnection.con.prepa... | 4 |
public void partitionDouble(FieldInfo fieldInfo, int partitions) {
FieldIterator iter = getFieldIterator(fieldInfo);
ArrayList<Double> values = new ArrayList<Double>();
ArrayList<Double> boundaries = new ArrayList<Double>();
// first pass, generate partition boundary
while (iter.hasNext()) {
Field f ... | 7 |
public CountingBloomFilter(final int len) {
super();
this.filter = new Short[len];
Arrays.fill(filter, (short)0);
} | 0 |
void generateLeafNodeList()
{
this.height = (int)((double)this.heightLimit * this.heightAttenuation);
if (this.height >= this.heightLimit)
{
this.height = this.heightLimit - 1;
}
int var1 = (int)(1.382D + Math.pow(this.leafDensity * (double)this.heightLimit / 13... | 8 |
public static <E> E sample(Counter<E> counter) {
double total = counter.totalCount();
double rand = random.nextDouble();
double sum = 0.0;
if (total <= 0.0) {
throw new RuntimeException("Non-positive counter total: " + total);
}
for (E key: counter.keySet()) {
double count = counter.getCount(k... | 4 |
public void run()
{
while (true)
{
try
{
Thread.sleep(10);
}
catch (InterruptedException e) {}
if(DSSUpdater.getHighLight() != highlight)
{
highlight = DSSUpdater.getHighLight();
DSSUpdater.getHighPathAr(dsa);
drawSomething = true;
}
... | 8 |
private int shiftKeys(int pos) {
// Shift entries with the same hash.
int last, slot;
for (;;) {
pos = ((last = pos) + 1) & mask;
while (used[pos]) {
slot = MurmurHash3.murmurhash3_x86_32(key, pos * sliceLength, sliceLength) & mask;
if (last <= pos ? last >= slot || slot > pos : last >= slot && slot... | 7 |
public static Class getOptionFormat(byte code) {
OptionFormat format = _DHO_FORMATS.get(code);
if (format == null) {
return null;
}
switch (format) {
case INET:
return InetAddress.class;
case INETS:
return InetAddress[].class;
case INT:
return int.class;
case SHORT:
return ... | 9 |
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.