id
stringlengths
36
36
text
stringlengths
1
1.25M
16d5d9d2-0795-468d-afa5-6007253282a8
@Test public void entre5Dias2() { inicial = new DateTime(2010, 07, 19, 11, 1, 0, 0); finall = new DateTime(2010, 07, 20, 14, 59, 0, 0); Tempo labor = calc.quantidadeDeHoras(inicial, finall, janela); assertEquals(9, labor.getHoras()); assertEquals(58, labor.getMinutos()); }
b70a5643-7313-42e2-8688-91e67099fcc7
@Test public void entreAnos() { inicial = new DateTime(2009, 12, 31, 14, 0, 0, 0); finall = new DateTime(2010, 1, 1, 12, 0, 0, 0); Tempo labor = calc.quantidadeDeHoras(inicial, finall, janela); assertEquals(8, labor.getHoras()); assertEquals(0, labor.getMinutos()); }
85c75042-9a9c-472f-8edb-3cf3712cc1c6
@Test public void entreFinaisDeSemana() { inicial = new DateTime(2010, 7, 9, 20, 0, 0, 0); finall = new DateTime(2010, 7, 12, 8, 1, 0, 0); Tempo labor = calc.quantidadeDeHoras(inicial, finall, janela); assertEquals(0, labor.getHoras()); assertEquals(1, labor.getMinutos()); }
21210539-7bd3-44bc-a995-acfe73e2cb07
@Test public void testezao01() { inicial = new DateTime(2012, 6, 4, 11, 35, 0, 0); finall = new DateTime(2012, 6, 4, 11, 37, 0, 0); Tempo labor = calc.quantidadeDeHoras(inicial, finall, janela); assertEquals(0, labor.getHoras()); assertEquals(2, labor.getMinutos()); }
73f8c295-bff2-48fc-8335-65ee886b9299
@Test public void testezao02() { inicial = new DateTime(2012, 6, 4, 8, 58, 0, 0); finall = new DateTime(2012, 6, 14, 14, 35, 0, 0); Tempo labor = calc.quantidadeDeHoras(inicial, finall, janela); assertEquals(2, labor.getDias()); assertEquals(19, labor.getHoras()); assertEquals(37, labor.getMinutos()); ...
46b2b699-1f5f-45c4-ac88-c2837274ac54
@Test public void testezao03() { inicial = new DateTime(2012, 6, 4, 8, 58, 0, 0); finall = new DateTime(2012, 6, 4, 8, 58, 0, 0); Tempo labor = calc.quantidadeDeHoras(inicial, finall, janela); assertEquals(0, labor.getDias()); assertEquals(0, labor.getHoras()); assertEquals(0, labor.getMinutos()); }
8cdbaa18-622a-43c3-993a-9b449f056ee8
public Main() { loadProperties(); initComponents(); setLocationRelativeTo(null); if(!isPasswordCorrect()) { System.exit(0); } }
13531485-8b96-44fd-9f97-2263c91773aa
private boolean isPasswordCorrect() { String passwordPropertyMd5 = properties.getProperty(Globals.PROPERTY_KEY_PASSWORD); //Comprobar si hay configurada una contraseña de acceso if(passwordPropertyMd5!=null) { //Solicitar contraseña de acceso PasswordDialog passwordDialog...
abbb2edf-6652-4a60-ac64-5b44d7af10dd
private void loadProperties() { try { properties.load(new FileReader(Globals.PROPERTIES_FILE_NAME)); String propLanguage = properties.getProperty(Globals.PROPERTY_KEY_LANGUAGE, Globals.DEFAULT_LANGUAGE); Locale.setDefault(new Locale(propLanguage)); } catch (FileNotFou...
f5eb2ed5-af74-4845-8e86-68015ff97c55
@SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jButtonSettings = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); addWindowListener(n...
eedb1d75-88c5-461e-8f4b-ba1505733b49
public void windowClosing(java.awt.event.WindowEvent evt) { formWindowClosing(evt); }
49e07c0c-0e8a-429a-8b25-bfb9cca4dbb2
public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonSettingsActionPerformed(evt); }
21f3aac7-04eb-4b59-b109-fed13cce980f
private void jButtonSettingsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSettingsActionPerformed SettingsDialog settingsDialog = new SettingsDialog(this, true); settingsDialog.setProperties(properties); settingsDialog.setVisible(true); }//GEN-LAST:event_jButtonS...
5d9a3214-cffb-4c44-b70b-45a828a2a305
private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing try { //Guardar las propiedades en el archivo properties.store(new FileWriter(Globals.PROPERTIES_FILE_NAME), ""); } catch (IOException ex) { Logger.getLogger(Main.class...
32b0bcb5-ab1f-4441-b582-821d1b803e5b
public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://down...
180e50ce-e0e0-4a50-83c4-2b3ca11102f5
public void run() { new Main().setVisible(true); }
bc90f09a-2657-4f88-bf28-08517a107103
public PasswordDialog(java.awt.Frame parent, boolean modal) { super(parent, modal); initComponents(); setResizable(false); setLocationRelativeTo(parent); getRootPane().setDefaultButton(jButtonOk); }
0d2ac19e-c1b0-47e4-a122-bd607c92ef57
public boolean isOkButtonPressed() { return OkButtonPressed; }
0c506c06-8acc-464c-9a5f-739060b1f1c2
public String getPasswordMd5() { return passwordMd5; }
af173ad7-5066-4c70-a081-f1993dec2169
@SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jLabel1 = new javax.swing.JLabel(); jPasswordField1 = new javax.swing.JPasswordField(); jButtonOk = new javax.swing.JButton(); ...
dbb537bb-4f42-47ad-836d-6f5901ec8619
public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonOkActionPerformed(evt); }
2968a92c-ebf4-4661-b7d2-67adb1f25236
public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonCancelActionPerformed(evt); }
97c4ff35-0081-4a5d-b0c1-1ead35174f95
private void jButtonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCancelActionPerformed OkButtonPressed = false; dispose(); }//GEN-LAST:event_jButtonCancelActionPerformed
bf31c742-0237-4f79-bb0e-b044e401b1b8
private void jButtonOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonOkActionPerformed passwordMd5 = Util.toMd5(jPasswordField1.getPassword(), true); OkButtonPressed = true; dispose(); }//GEN-LAST:event_jButtonOkActionPerformed
6e8982d4-f578-451b-95d7-0a548e51f063
public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://down...
3a824f65-0489-4100-93a3-32ee0e0564fa
public void run() { PasswordDialog dialog = new PasswordDialog(new javax.swing.JFrame(), true); dialog.addWindowListener(new java.awt.event.WindowAdapter() { @Override public void windowClosing(java.awt.event.WindowEvent e) { ...
f79069fc-7bf7-4ca2-a6a4-a155e4968520
@Override public void windowClosing(java.awt.event.WindowEvent e) { System.exit(0); }
1907248d-8d67-4b1d-8fa7-85af0a3ccb5b
public static String toMd5(char[] input, boolean clearInput) { String md5 = null; if (input != null) { try { //Convertir la entrada a array de bytes, ya que así se requiere // para poder codificarla a MD5. No se debe conviertir a String // po...
328a5eee-61eb-4767-80b2-97ca2441caa6
public static byte[] toBytes(char[] chars) { CharBuffer charBuffer = CharBuffer.wrap(chars); ByteBuffer byteBuffer = Charset.forName("UTF-8").encode(charBuffer); byte[] bytes = Arrays.copyOfRange(byteBuffer.array(), byteBuffer.position(), byteBuffer.limit()); Arrays.fill(...
c50bb517-3820-4edd-a952-8eeb21dcad03
public static void restartJarApplication(Class appClass) { try { final String javaBin = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java"; final File currentJar = new File(appClass.getProtectionDomain().getCodeSource().getLocation().toURI()); ...
bd80535b-77ae-40ea-b542-bb1041376d5f
public SettingsDialog(java.awt.Frame parent, boolean modal) { super(parent, modal); initComponents(); setResizable(false); setLocationRelativeTo(parent); getRootPane().setDefaultButton(jButtonOk); }
44bce476-f770-4b8c-ae1e-5740b190191e
public void setProperties(Properties properties) { this.properties = properties; fillComboBoxLanguages(); //Si no hay una contraseña en el archivo de propiedades, activar campos // para obligar nueva contraseña if(properties.getProperty(Globals.PROPERTY_KEY_PA...
138b2fcb-7c32-445b-af8e-bb8dd2d99b40
public boolean isOkButtonPressed() { return okButtonPressed; }
cc4c251f-fc75-4967-aa5e-c0fbdc87bb6f
public void fillComboBoxLanguages() { //Crear un array con los nombres completos de los idiomas String[] labelLanguages = new String[Globals.LANGUAGES.length]; for (int i = 0; i < labelLanguages.length; i++) { //Obtener el nombre de cada idioma labelLanguages[i] = (new Lo...
8a9e7834-2b53-49cd-b846-a7648c6d2151
public static boolean isPasswordValid(char[] password, int minLength, boolean digitRequired, boolean lowerCaseRequired, boolean upperCaseRequired, boolean specialCharRequired) { boolean hasDigit = false; boolean hasLower = false; boolean hasUpper = false; ...
ced42023-7b64-46fa-a2c0-f9d029b1cc82
@SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jTextField1 = new javax.swing.JTextField(); jButtonCancel = new javax.swing.JButton(); jButtonOk = new javax.swing.JButton(); ...
231d820f-43bd-4ec5-9b91-fcd70234cdd8
public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonCancelActionPerformed(evt); }
dcb5b704-bb56-4103-bc35-ea7c4f0b252a
public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonOkActionPerformed(evt); }
b7f16504-8395-4cb4-b2cb-e8e0ed366753
public void actionPerformed(java.awt.event.ActionEvent evt) { jCheckBox1ActionPerformed(evt); }
6f29d063-cb91-471a-806a-8d28a0a4b473
private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox1ActionPerformed jPasswordFieldOld.setEnabled(jCheckBox1.isSelected()); jPasswordFieldNew.setEnabled(jCheckBox1.isSelected()); jPasswordFieldConfirm.setEnabled(jCheckBox1.isSelected()); }//GEN-...
b6fb6c19-01da-4921-80c8-f595aa93af9a
private void jButtonOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonOkActionPerformed boolean error = false; char[] oldPassword = null, newPassword = null, confirmPassword = null; //Obtener la posición del idioma seleccionado en la lista desplegable int index...
07d36219-4004-405c-a829-984f0836264f
private void jButtonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCancelActionPerformed dispose(); }//GEN-LAST:event_jButtonCancelActionPerformed
f01e063b-57e5-4012-97b7-eabf9025555a
public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://down...
86edc07a-3267-4a5d-a7b9-736a4d5f617a
public void run() { SettingsDialog dialog = new SettingsDialog(new javax.swing.JFrame(), true); dialog.addWindowListener(new java.awt.event.WindowAdapter() { @Override public void windowClosing(java.awt.event.WindowEvent e) { ...
b9a7d609-6ddd-4fb3-9f6e-48fc9eab4bb4
@Override public void windowClosing(java.awt.event.WindowEvent e) { System.exit(0); }
5a0056c1-d3aa-4bff-a485-859710735c57
void call(int index);
01e64dcb-1cc0-4801-a60f-04d336828edd
RunnableBlock(final Runnable task) { _task = task; }
650c764b-5106-44ef-9975-97648c5daf78
public void call(final int index) { _task.run(); }
0a1838aa-0769-486a-874f-bebf0e3af79c
public static void parallel(final int numThreads, final Runnable block) { parallel(numThreads, new RunnableBlock(block)); }
7f1d1cb5-8f52-49c1-b6eb-cac938e9067c
public static void parallel(final int numThreads, final Block block) { final Thread[] threads = new Thread[numThreads]; final Throwable[] failure = { null }; for (int i = 0; i < threads.length; ++i) { final int index = i; threads[i] = new Thread("worker #" + i) { @Override public void run() { t...
63778f58-b3f8-4394-a6b7-27aa0885562b
@Override public void run() { try { block.call(index); } catch (final Throwable xx) { failure[0] = xx; } }
2762d24c-1a66-413c-a1f3-bd22f2296194
public static long timeParallel(final int numThreads, final Runnable block) { return timeParallel(numThreads, new RunnableBlock(block)); }
c58963df-ddec-4b07-b77f-53ea757e2ce3
public static long timeParallel(final int numThreads, final Block block) { final long[] times = new long[2]; final CyclicBarrier barrier = new CyclicBarrier(numThreads, new Runnable() { public void run() { times[0] = times[1]; times[1] = System.currentTimeMillis(); } }); parallel(num...
b67af223-28e5-4f71-a705-cd16af63dd7f
public void run() { times[0] = times[1]; times[1] = System.currentTimeMillis(); }
ddf5c94e-1856-49a8-9d1a-3aeda2e8562a
public void call(final int index) { try { barrier.await(); } catch (final Exception xx) { throw new RuntimeException("unexpected", xx); } try { block.call(index); } finally { try { barrier.await(); } catch (final Exception xx) { throw new RuntimeException("unexpe...
5afbcb68-aef8-41c9-9999-68e6085f13b7
private static int getHash(int x, int bits) { int mask = (int) ((1L << (1 << bits)) - 1); return x & mask; }
ba73fd69-78a7-4fd6-84ee-2ff892ea780b
public static void main(String[] args) { ConcurrentTester tester = new ConcurrentTester(); /*numThreads = Integer.parseInt(args[0]); outerPasses = workers / numThreads; boolean withoutRemove = args[1].equals("without_remove");*/ tester.testConcurrent(true); }
5507a5f7-c7ef-4098-9e23-f79fadaae30d
public void testConcurrent(final boolean withoutRemove) { final UHTree map = UHTreeCreator.getNewUHTree(order); final Random random = new Random(0); final int keyRange = 500000; // Rango de los elementos a ingresar en el // UHTree. final RandomDistribution.Zipf zipf = new RandomDistribution.Zipf( r...
f9416459-9084-4c58-b043-164ebd765d51
public void run() { for (int inner = 0; inner < innerOps; ++inner) { final int pct = random.nextInt(100); final int key = zipf.nextInt(); final int hash = getHash(key, order); if (pct < putPct) { map.add(hash, key); } else if (pct < searchPct || withoutRemove) { map.cont...
041c0d5e-b59a-4c5e-9ac6-607f4cfcfa1f
public UHList() { }
0c493aa5-1e62-4fc0-9c42-b4549a6c948a
public UHList(Object value) { addNewElement(value); }
b22b800f-329b-4bc9-a685-0f1b351347af
public void addNewElement(Object value) { if (value instanceof UHList) { set.putAll(((UHList) value).set); } else { UHElement newElement = new UHElement(value); set.put(newElement, newElement); } }
b9f26e3e-f304-47cc-acbd-13667f0ec714
public boolean contains(Object value, UHNode uhNode) { UHElement element = set.get(new UHElement(value)); if (element == null) { return false; } else { element.incr(); if (best == null || best.getCount() < element.getCount()) { best = element; } uhNode.updateBest(best); return true; } }
b8343ae8-2279-425c-86e4-8653a0e83056
public boolean isEmpty() { return set.isEmpty(); }
5ac54507-ada5-467c-b968-318c36ac7ce6
public ConcurrentHashMap<UHElement, UHElement> getSet() { return set; }
28b8e4e4-10fd-4930-a257-ec039ed3f210
public boolean remove(Object value) { assert !(value instanceof UHList); boolean success = set.remove(new UHElement(value)) != null; if (success && value.equals(best)) best = null; return success; }
6522e848-c220-49f8-b15d-0ceecf1ac1cc
public UHTree(int order) { root = new UHNode(order); }
c62b405d-d26e-40f3-97d1-019cef66d06a
public boolean contains(int hash, Object value) { return root.contains(hash, value); }
aafb0719-cc77-426d-8374-9a51c7252e3d
public boolean remove(int hash, Object value) { return root.remove(hash, value); }
85ce2293-8cd9-4251-93b1-616b686128df
public void add(int hash, Object value) { root.add(hash, value); }
419caf03-a1d4-4072-9332-e7934e889337
public boolean isEmpty() { return root.isEmpty(); }
fe0aab4f-7915-4cbc-806f-75c1a2a01455
public int getMinHash() { return root.getMinHash(); }
2190f24b-08b7-40b9-802b-543e966f7a5b
public UHElement(Object value) { this.value = value; }
8163a93d-bceb-4d53-9b4e-344fb7a68955
public void incr() { count++; }
f1e05707-8991-4a42-bc1b-58c33428b256
public int getCount() { return count; }
0147c637-0888-4694-b9fb-49a22ab463f0
public Object getValue() { return value; }
a4ad3a77-d910-4ebb-8fe1-99fdb86180ce
@Override public boolean equals(Object other) { if (other instanceof UHElement) { UHElement uhElement = (UHElement) other; return value.equals(uhElement.getValue()); } else return value.equals(other); }
e93a3edb-7953-41d4-9d1c-c03751aa4941
@Override public int hashCode() { return value.hashCode(); }
3739bd1b-35bb-4327-bd16-c907ed669ae5
public static UHTree getNewUHTree(int order) { return new UHTree(order); }
6c386e94-6395-4405-8565-39427535538d
public static IntegerHeap getNewIntegerHeap(int order) { if (order <= 2) { return new UHBitmaskHeap(order); } else { return new UHNode(order); } }
950da3b0-bcd5-4609-a772-6f2c770157fd
public int nextInt();
de5e4b53-3516-49ec-a6f3-12c24b2faa1a
public Flat(Random random, int min, int max) { if (min >= max) { throw new IllegalArgumentException("Invalid range"); } this.random = random; this.min = min; this.max = max; }
1f4351c7-f4c3-4824-a0a9-937c6fdd15ac
@Override public int nextInt() { return random.nextInt(max - min) + min; }
30852fd2-0aa3-4265-bd89-692a74bfa0ba
public Zipf(Random r, int min, int max, double sigma) { this(r, min, max, sigma, DEFAULT_EPSILON); }
729a054f-7f58-43ff-9f98-08eed4bcc33f
public Zipf(Random r, int min, int max, double sigma, double epsilon) { if ((max <= min) || (sigma <= 1) || (epsilon <= 0) || (epsilon >= 0.5)) { throw new IllegalArgumentException("Invalid arguments"); } random = r; k = new ArrayList<Integer>(); v = new ArrayList<Double>(); double sum = 0; ...
679394b1-b54b-4243-9bfe-8d8e699af5a8
@Override public int nextInt() { double d = random.nextDouble(); int idx = Collections.binarySearch(v, d); if (idx > 0) { ++idx; } else { idx = -(idx + 1); } if (idx >= v.size()) { idx = v.size() - 1; } if (idx == 0) { return k.get(0); } int ceiling = k.get(idx); i...
8775bc4c-c19e-49aa-ad73-0e8b235b6d66
private static double select(int n, int k) { double ret = 1.0; for (int i = k + 1; i <= n; ++i) { ret *= (double) i / (i - k); } return ret; }
2e46fd50-89d7-4888-840e-6ee486236431
private static double power(double p, int k) { return Math.exp(k * Math.log(p)); }
74052a79-f37b-4f1d-958e-0a5faf8bc42e
public Binomial(Random random, int min, int max, double p) { if (min >= max) { throw new IllegalArgumentException("Invalid range"); } this.random = random; this.min = min; this.n = max - min - 1; if (n > 0) { v = new double[n + 1]; double sum = 0.0; for (int i = 0; i <= n; ++i) { ...
de02396e-8627-4fda-92fb-1e6ba8424ab2
@Override public int nextInt() { if (v == null) { return min; } double d = random.nextDouble(); int idx = Arrays.binarySearch(v, d); if (idx > 0) { ++idx; } else { idx = -(idx + 1); } if (idx >= v.length) { idx = v.length - 1; } return idx + min; }
74bd1907-0dc9-46cc-b2b7-88238822f293
public UHBitmaskHeap(int order) { mask = 0; }
ce0941b5-92b5-4137-9b41-066e73404b60
public boolean isEmpty() { return mask == 0; }
8d60bbac-0b21-4136-b902-df6aa4e9f654
public void add(int x, Object y) { mask |= 1 << x; }
48d558ca-6aff-4e08-8319-bff2a4bf9544
public boolean remove(int x, Object y) { if ((mask & (1 << x)) != 0) { mask ^= 1 << x; return true; } else { return false; } }
63a0aca5-1fd6-4f4a-a4c3-1ea5d2030301
public int getMinHash() { assert mask != 0; return Integer.numberOfTrailingZeros(mask); }
a6941b9e-6a9b-41bd-bf9b-149d03bf135b
public UHNode(int order) { isEmpty = true; this.order = order; shift = 1 << (order - 1); max = (int) ((1L << (1 << order)) - 1); minElements = new UHList(); HQ = UHTreeCreator.getNewIntegerHeap(order - 1); LQ = new UHNode[max + 1]; }
b612bfac-41fc-4959-acd6-110652687c4c
public boolean isEmpty() { assert !isEmpty || isEmpty && best == null; return isEmpty; }
0e7b1638-5278-4ad3-9fb8-0d0364a20cb5
public int getMinHash() { assert isEmpty == false; return min; }
44c49cdd-1895-465f-872d-6dacc356e9b1
public UHList getMinElements() { assert isEmpty == false; return minElements; }
92ba0b6c-6e3b-4aeb-85c3-263a4ab13fee
public static int compareUnsignedInt(int a, int b) { long val = (a & 0xffffffffL) - (b & 0xffffffffL); return val < 0 ? -1 : val > 0 ? 1 : 0; }