Example #1
0
 @Test
 public void testSelfEdges() {
   UndirectedGraph q = new UndirectedGraph();
   q.add();
   q.add();
   q.add();
   q.add();
   q.add();
   q.add();
   q.add();
   q.add();
   q.add(1, 8);
   q.add(1, 1);
   q.add(1, 2);
   q.add(1, 3);
   q.add(1, 4);
   ArrayList<Integer> output2 = new ArrayList<>();
   for (int node : q.successors(1)) {
     output2.add(node);
   }
   List<Integer> expected2 = Arrays.asList(8, 1, 2, 3, 4);
   assertTrue(output2.equals(expected2));
   assertEquals(5, q.edgeSize());
   q.remove(2);
   ArrayList<Integer> output3 = new ArrayList<>();
   for (int node : q.successors(1)) {
     output3.add(node);
   }
   List<Integer> expected3 = Arrays.asList(8, 1, 3, 4);
   assertTrue(output3.equals(expected3));
   assertEquals(4, q.edgeSize());
 }
Example #2
0
  /**
   * This operation is used to check equality between this Polygon and another Polygon. It returns
   * true if the Polygons are equal and false if they are not.
   *
   * @param otherObject
   *     <p>The other Object that should be compared with this one.
   * @return
   *     <p>True if the Objects are equal, false otherwise.
   */
  @Override
  public boolean equals(Object otherObject) {

    // By default, the objects are not equivalent.
    boolean equals = false;

    // Check the reference.
    if (this == otherObject) {
      equals = true;
    }
    // Check the information stored in the other object.
    else if (otherObject != null && otherObject instanceof Polygon) {

      // We can now cast the other object.
      Polygon polygon = (Polygon) otherObject;

      // Compare the values between the two objects.
      equals =
          (super.equals(otherObject)
              && vertices.equals(polygon.vertices)
              && edges.equals(polygon.edges)
              && edgeProperties.equals(polygon.edgeProperties)
              && polygonProperties.equals(polygon.polygonProperties));
    }

    return equals;
  }
Example #3
0
  @Test
  public <T> void testRemoveDuplicates() {

    ArrayList<String> testArrayList = new ArrayList<String>();
    MiscUtil.removeDuplicates(testArrayList);
    assertTrue(testArrayList.equals(new ArrayList<String>()));

    testArrayList = new ArrayList<String>(Arrays.asList("b", "a"));
    MiscUtil.removeDuplicates(testArrayList);
    assertTrue(testArrayList.equals(new ArrayList<String>(Arrays.asList("b", "a"))));

    testArrayList = new ArrayList<String>(Arrays.asList("b", "a", "b"));
    MiscUtil.removeDuplicates(testArrayList);
    assertTrue(testArrayList.equals(new ArrayList<String>(Arrays.asList("b", "a"))));

    testArrayList = new ArrayList<String>(Arrays.asList("b", "a", "b", "b"));
    MiscUtil.removeDuplicates(testArrayList);
    assertTrue(testArrayList.equals(new ArrayList<String>(Arrays.asList("b", "a"))));

    testArrayList = new ArrayList<String>(Arrays.asList("a", "b", "b", "b", "b"));
    MiscUtil.removeDuplicates(testArrayList);
    assertTrue(testArrayList.equals(new ArrayList<String>(Arrays.asList("a", "b"))));

    LinkedList<String> testLinkedList = new LinkedList<String>(Arrays.asList("b", "a", "b"));
    MiscUtil.removeDuplicates(testLinkedList);
    assertTrue(testLinkedList.equals(new LinkedList<String>(Arrays.asList("b", "a"))));

    testLinkedList = new LinkedList<String>(Arrays.asList("b", "a", "b", "b"));
    MiscUtil.removeDuplicates(testLinkedList);
    assertTrue(testLinkedList.equals(new LinkedList<String>(Arrays.asList("b", "a"))));

    testLinkedList = new LinkedList<String>(Arrays.asList("a", "b", "b", "b", "b"));
    MiscUtil.removeDuplicates(testLinkedList);
    assertTrue(testLinkedList.equals(new LinkedList<String>(Arrays.asList("a", "b"))));
  }
Example #4
0
  /** Undo the command */
  @Override
  public void undo() {
    logger.log(Level.INFO, "Command UNDO DELETE");
    taskList = storage.getTaskList();
    ArrayList<Task> displayList = MainLogic.getDisplayList();
    for (int i = 0; i < userInput.getTasksToDelete().size(); i++) {
      Task task = userInput.getTasksToDelete().get(i);

      if (task.isRecurring() && userInput.getIsAll()) {
        Task t = task.getHead();
        for (int j = 0; j < userInput.getRecurList().size(); j++) {
          taskList.add(userInput.getRecurList().get(j));
          if (!displayList.equals(taskList)) {
            displayList.add(userInput.getRecurList().get(j));
          }
        }
        t.setRecurList(userInput.getRecurList());
      } else if (task.isRecurring()) {
        taskList.add(task);
        if (!displayList.equals(taskList)) {
          displayList.add(task);
        }
        Task t = task.getHead();
        t.getRecurList().add(task);
      } else {
        taskList.add(task);
        if (!displayList.equals(taskList)) {
          displayList.add(task);
        }
      }
    }
    storage.saveFile();

    feedback.setMessage(MSG_SUCCESS_UNDO);
  }
 @Override
 public boolean equals(Object obj) {
   State state = (State) obj;
   return currentCity.equals(state.currentCity)
       && availableTasks.equals(state.availableTasks)
       && carriedTasks.equals(state.carriedTasks);
 }
Example #6
0
  @Test
  public void directedGraph() {
    DirectedGraph g = new DirectedGraph();
    g.add();
    g.add();
    assertEquals(2, g.vertexSize());
    g.add();
    assertEquals(3, g.maxVertex());
    assertEquals(false, g.contains(4));
    assertEquals(true, g.contains(2));
    g.add(1, 2);
    g.add(2, 3);
    assertEquals(1, g.predecessor(2, 0));
    assertEquals(2, g.edgeSize());
    g.add(1, 3);
    assertEquals(2, g.inDegree(3));
    assertEquals(3, g.edgeSize());
    assertEquals(true, g.contains(1, 3));
    assertEquals(false, g.contains(2, 1));
    assertEquals(2, g.outDegree(1));
    assertEquals(2, g.successor(1, 0));
    assertEquals(3, g.successor(1, 1));
    g.remove(1);
    assertEquals(false, g.contains(1));
    assertEquals(2, g.vertexSize());
    assertEquals(1, g.edgeSize());
    g.add();
    assertEquals(true, g.contains(1));
    DirectedGraph p = new DirectedGraph();
    p.add();
    p.add();
    p.add();
    p.add();
    p.add(2, 1);
    p.add(3, 1);
    p.add(4, 1);
    ArrayList<Integer> output = new ArrayList<>();

    for (int node : p.predecessors(1)) {
      output.add(node);
    }

    List<Integer> expected = Arrays.asList(2, 3, 4);
    assertTrue(output.equals(expected));
    DirectedGraph q = new DirectedGraph();
    q.add();
    q.add();
    q.add();
    q.add(2, 3);
    q.add(1, 3);
    q.remove(2);
    ArrayList<Integer> output2 = new ArrayList<>();
    for (int node : q.predecessors(3)) {
      output2.add(node);
    }
    List<Integer> expected2 = Arrays.asList(1);
    assertTrue(output2.equals(expected2));
  }
Example #7
0
 /**
  * Equality test.
  *
  * <p>Words are equal if they have the same frequency, the same spellings, and the same
  * attributes.
  */
 @Override
 public boolean equals(Object o) {
   if (o == this) return true;
   if (!(o instanceof Word)) return false;
   Word w = (Word) o;
   return mFrequency == w.mFrequency
       && mWord.equals(w.mWord)
       && mShortcutTargets.equals(w.mShortcutTargets)
       && mBigrams.equals(w.mBigrams);
 }
Example #8
0
 @SuppressWarnings("all")
 public boolean equals(Object o) {
   if (!(o instanceof MultiDOFJointState)) return false;
   MultiDOFJointState other = (MultiDOFJointState) o;
   return stamp.equals(other.stamp)
       && joint_names.equals(other.joint_names)
       && frame_ids.equals(other.frame_ids)
       && child_frame_ids.equals(other.child_frame_ids)
       && poses.equals(other.poses)
       && true;
 }
  /** @tests java.util.ArrayList#clone() */
  public void test_clone() {
    // Test for method java.lang.Object java.util.ArrayList.clone()
    ArrayList x = (ArrayList) (((ArrayList) (alist)).clone());
    assertTrue("Cloned list was inequal to original", x.equals(alist));
    for (int i = 0; i < alist.size(); i++)
      assertTrue("Cloned list contains incorrect elements", alist.get(i) == x.get(i));

    alist.add(null);
    alist.add(25, null);
    x = (ArrayList) (((ArrayList) (alist)).clone());
    assertTrue("nulls test - Cloned list was inequal to original", x.equals(alist));
    for (int i = 0; i < alist.size(); i++)
      assertTrue("nulls test - Cloned list contains incorrect elements", alist.get(i) == x.get(i));
  }
 @Override
 public boolean equals(final Object obj) {
   if (this == obj) {
     return true;
   }
   if (obj == null) {
     return false;
   }
   if (getClass() != obj.getClass()) {
     return false;
   }
   ManageMessage other = (ManageMessage) obj;
   if (chunks == null) {
     if (other.chunks != null) {
       return false;
     }
   } else if (!chunks.equals(other.chunks)) {
     return false;
   }
   if (receivers == null) {
     if (other.receivers != null) {
       return false;
     }
   } else if (!receivers.equals(other.receivers)) {
     return false;
   }
   return true;
 }
Example #11
0
 /** Equals method */
 @Override
 public boolean equals(Object obj) {
   if (this == obj) {
     return true;
   }
   if (obj == null) {
     return false;
   }
   if (getClass() != obj.getClass()) {
     return false;
   }
   Showpiece other = (Showpiece) obj;
   if (Id != other.Id) {
     return false;
   }
   if (description == null) {
     if (other.description != null) return false;
   } else if (!description.equals(other.description)) return false;
   if (name == null) {
     if (other.name != null) return false;
   } else if (!name.equals(other.name)) return false;
   if (showpiece == null) {
     if (other.showpiece != null) return false;
   } else if (!showpiece.equals(other.showpiece)) return false;
   return true;
 }
 public void parseConferencePresence(PresencePacket packet, Account account) {
   PgpEngine mPgpEngine = mXmppConnectionService.getPgpEngine();
   final Conversation conversation =
       packet.getFrom() == null
           ? null
           : mXmppConnectionService.find(account, packet.getFrom().toBareJid());
   if (conversation != null) {
     final MucOptions mucOptions = conversation.getMucOptions();
     boolean before = mucOptions.online();
     int count = mucOptions.getUsers().size();
     final ArrayList<MucOptions.User> tileUserBefore =
         new ArrayList<>(
             mucOptions.getUsers().subList(0, Math.min(mucOptions.getUsers().size(), 5)));
     mucOptions.processPacket(packet, mPgpEngine);
     final ArrayList<MucOptions.User> tileUserAfter =
         new ArrayList<>(
             mucOptions.getUsers().subList(0, Math.min(mucOptions.getUsers().size(), 5)));
     if (!tileUserAfter.equals(tileUserBefore)) {
       mXmppConnectionService.getAvatarService().clear(conversation);
     }
     if (before != mucOptions.online()
         || (mucOptions.online() && count != mucOptions.getUsers().size())) {
       mXmppConnectionService.updateConversationUi();
     } else if (mucOptions.online()) {
       mXmppConnectionService.updateMucRosterUi();
     }
   }
 }
Example #13
0
 @Test
 public void undirectedGraph() {
   UndirectedGraph g = new UndirectedGraph();
   g.add();
   g.add();
   g.add(1, 2);
   assertEquals(1, g.edgeSize());
   assertEquals(2, g.successor(1, 0));
   assertEquals(2, g.predecessor(1, 0));
   g.add();
   g.add();
   g.add(1, 3);
   g.add(1, 4);
   ArrayList<Integer> output = new ArrayList<>();
   for (int node : g.successors(1)) {
     output.add(node);
   }
   List<Integer> expected = Arrays.asList(2, 3, 4);
   assertTrue(output.equals(expected));
   g.remove(1, 4);
   assertFalse(g.contains(1, 4));
   assertFalse(g.contains(4, 1));
   UndirectedGraph p = new UndirectedGraph();
   p.add();
   p.add();
   p.add();
   p.add();
   p.add(2, 1);
   p.add(3, 1);
   p.add(4, 1);
   p.add(2, 3);
   p.remove(1);
   assertEquals(1, p.edgeSize());
 }
  /**
   * Saves the reminders, if they changed. Returns true if the database was updated.
   *
   * @param cr the ContentResolver
   * @param taskId the id of the task whose reminders are being updated
   * @param reminderMinutes the array of reminders set by the user
   * @param originalMinutes the original array of reminders
   * @return true if the database was updated
   */
  static boolean saveReminders(
      ContentResolver cr,
      long taskId,
      ArrayList<Integer> reminderMinutes,
      ArrayList<Integer> originalMinutes) {
    // If the reminders have not changed, then don't update the database
    if (reminderMinutes.equals(originalMinutes)) {
      return false;
    }

    // Delete all the existing reminders for this event
    String where = ReminderProvider.Reminders.TASK_ID + "=?";
    String[] args = new String[] {Long.toString(taskId)};
    cr.delete(ReminderProvider.Reminders.CONTENT_URI, where, args);

    ContentValues values = new ContentValues();
    int len = reminderMinutes.size();

    // Insert the new reminders, if any
    for (int i = 0; i < len; i++) {
      int minutes = reminderMinutes.get(i);

      values.clear();
      values.put(ReminderProvider.Reminders.MINUTES, minutes);
      values.put(ReminderProvider.Reminders.METHOD, ReminderProvider.Reminders.METHOD_ALERT);
      values.put(ReminderProvider.Reminders.TASK_ID, taskId);
      cr.insert(ReminderProvider.Reminders.CONTENT_URI, values);
    }
    return true;
  }
 /**
  * Realizar una consulta en la BD con el fin de imprimir TODOS los resultados. Las consultas
  * realizadas no se paginaran.
  *
  * @param mapping ActionMapping - Objeto de mapeo propio de Struts
  * @param form ActionForm - Objeto que encapsula los datos del Formulario JSP invocador
  * @param request HttpServletRequest - Objeto de Clase HttpServletRequest que actua sobre el
  *     formulario JSP Invocador
  * @param response HttpServletResponse - Objeto de Clase HttpServletResponse que actua sobre el
  *     formulario JSP Invocador
  * @throws IOException, ServletException - Excepciones de Tipo IO y de Servlet
  * @return ActionForward - Objeto que indica el forward o siguiente paso.
  */
 public ActionForward consultar(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
     throws IOException, ServletException {
   String nextPage = "";
   UsuarioTO objetoTo = new UsuarioTO();
   UsuarioServicio servicio = new UsuarioServicio();
   servicio.objDataSession = DatosSession.poblarDatosSession(request);
   try {
     UsuarioForm objetoForm = (UsuarioForm) form;
     objetoTo = cargarInformacion(objetoForm);
     ArrayList<Object> results =
         servicio.servicioConsulta((Object) objetoTo, 1, filtrosAdicionales(0, request));
     objetoForm.setResults(results);
     objetoForm.setVar_Iniciopaginacion(String.valueOf(objetoForm.getVar_Iniciopaginacion()));
     objetoForm.setVar_Totalregistros(String.valueOf(objetoForm.getVar_Totalregistros()));
     nextPage = "consultar";
     if (results.equals(null)) {
       errors.add("error usuario", new ActionMessage("error.search.criteria.missing"));
       nextPage = "error";
     }
   } catch (Exception e) {
     errors.add("error usuario", new ActionMessage("error.search.criteria.missing"));
     System.out.println("Error en UsuarioDSP.consultar: " + e.toString());
     nextPage = "error";
   }
   return mapping.findForward(nextPage);
 }
Example #16
0
  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;
    if (!super.equals(o)) return false;

    TwitterStreamImpl that = (TwitterStreamImpl) o;

    if (handler != null ? !handler.equals(that.handler) : that.handler != null) return false;
    if (http != null ? !http.equals(that.http) : that.http != null) return false;
    if (lifeCycleListeners != null
        ? !lifeCycleListeners.equals(that.lifeCycleListeners)
        : that.lifeCycleListeners != null) return false;
    if (stallWarningsGetParam != null
        ? !stallWarningsGetParam.equals(that.stallWarningsGetParam)
        : that.stallWarningsGetParam != null) return false;
    if (stallWarningsParam != null
        ? !stallWarningsParam.equals(that.stallWarningsParam)
        : that.stallWarningsParam != null) return false;
    if (streamListeners != null
        ? !streamListeners.equals(that.streamListeners)
        : that.streamListeners != null) return false;

    return true;
  }
Example #17
0
 /* (non-Javadoc)
  * @see java.lang.Object#equals(java.lang.Object)
  */
 @Override
 public boolean equals(Object obj) {
   if (this == obj) {
     return true;
   }
   if (obj == null) {
     return false;
   }
   if (!(obj instanceof Serie)) {
     return false;
   }
   Serie other = (Serie) obj;
   if (high != other.high) {
     return false;
   }
   if (low != other.low) {
     return false;
   }
   if (name == null) {
     if (other.name != null) {
       return false;
     }
   } else if (!name.equals(other.name)) {
     return false;
   }
   if (runners == null) {
     if (other.runners != null) {
       return false;
     }
   } else if (!runners.equals(other.runners)) {
     return false;
   }
   return true;
 }
 /**
  * Updates the properties.
  *
  * @return true, if something has changed (new properties or properties were removed)
  */
 public boolean updateProperties() {
   ArrayList<Property> tmp = new ArrayList<Property>();
   try {
     tmp.addAll(PropertyDAO.getAllResultProperties());
     firstInstancePropertyColumn = COL_PROPERTY + tmp.size();
     for (int i = tmp.size() - 1; i >= 0; i--) {
       if (tmp.get(i).isMultiple()) {
         tmp.remove(i);
       }
     }
   } catch (Exception e) {
     if (edacc.ErrorLogger.DEBUG) {
       e.printStackTrace();
     }
   }
   if (!tmp.equals(properties)) {
     properties = tmp;
     columns = java.util.Arrays.copyOf(columns, CONST_COLUMNS.length + properties.size());
     int j = 0;
     for (int i = CONST_COLUMNS.length; i < columns.length; i++) {
       columns[i] = properties.get(j).getName();
       j++;
     }
     this.fireTableStructureChanged();
     return true;
   }
   return false;
 }
Example #19
0
  public boolean equals(Object obj) {
    if (obj instanceof ConfigCategory) {
      ConfigCategory cat = (ConfigCategory) obj;
      return name.equals(cat.name) && children.equals(cat.children);
    }

    return false;
  }
Example #20
0
 @Override
 public boolean equals(Object o) {
   if (this == o) return true;
   // TODO: why not allow equality to non-HashIndex indices?
   if (!(o instanceof HashIndex)) return false;
   HashIndex hashIndex = (HashIndex) o;
   return indexes.equals(hashIndex.indexes) && objects.equals(hashIndex.objects);
 }
Example #21
0
 public boolean equals(Object o) {
   if (o instanceof Company) {
     Company c = (Company) o;
     return name.equals(c.name) && employees.equals(c.employees);
   } else {
     return false;
   }
 }
Example #22
0
 /**
  * Compares an Object to the current Garage object to determine equality
  *
  * @param o the Object to be compared against
  * @return true if equal, false otherwise
  */
 @Override
 public boolean equals(Object o) {
   if (!(o instanceof Garage)) return false;
   else {
     Garage test = (Garage) o;
     return cars.equals(test.getCars());
   }
 }
Example #23
0
 /**
  * An equals method used to compare two Humanoids.
  *
  * @param o : Another humanoid object to compare to.
  * @return : True if the Humanoids are the same, false if not.
  */
 @Override
 public boolean equals(Object o) {
   if (!(o instanceof Humanoid)) return false;
   Humanoid h = (Humanoid) o;
   return (health == h.health)
       && (inventory.equals(h.inventory))
       && name.equals(h.name)
       && currentRoom.equals(h.currentRoom);
 }
Example #24
0
  /**
   * Prune raptor data to include only routes and boardings which have trips today. Doesn't actually
   * improve speed
   */
  @SuppressWarnings("unchecked")
  private RaptorData pruneDataForServiceDays(Graph graph, ArrayList<ServiceDay> serviceDays) {

    if (serviceDays.equals(cachedServiceDays)) return cachedRaptorData;
    RaptorData data = graph.getService(RaptorDataService.class).getData();
    RaptorData pruned = new RaptorData();
    pruned.raptorStopsForStopId = data.raptorStopsForStopId;
    pruned.stops = data.stops;
    pruned.routes = new ArrayList<RaptorRoute>();
    pruned.routesForStop = new List[pruned.stops.length];

    for (RaptorRoute route : data.routes) {
      ArrayList<Integer> keep = new ArrayList<Integer>();

      for (int i = 0; i < route.boards[0].length; ++i) {
        Edge board = route.boards[0][i];
        int serviceId;
        if (board instanceof TransitBoardAlight) {
          serviceId = ((TransitBoardAlight) board).getPattern().getServiceId();
        } else {
          log.debug("Unexpected nonboard among boards");
          continue;
        }
        for (ServiceDay day : serviceDays) {
          if (day.serviceIdRunning(serviceId)) {
            keep.add(i);
            break;
          }
        }
      }
      if (keep.isEmpty()) continue;
      int nPatterns = keep.size();
      RaptorRoute prunedRoute = new RaptorRoute(route.getNStops(), nPatterns);
      for (int stop = 0; stop < route.getNStops() - 1; ++stop) {
        for (int pattern = 0; pattern < nPatterns; ++pattern) {
          prunedRoute.boards[stop][pattern] = route.boards[stop][keep.get(pattern)];
        }
      }
      pruned.routes.add(route);
      for (RaptorStop stop : route.stops) {
        List<RaptorRoute> routes = pruned.routesForStop[stop.index];
        if (routes == null) {
          routes = new ArrayList<RaptorRoute>();
          pruned.routesForStop[stop.index] = routes;
        }
        routes.add(route);
      }
    }
    for (RaptorStop stop : data.stops) {
      if (pruned.routesForStop[stop.index] == null) {
        pruned.routesForStop[stop.index] = Collections.emptyList();
      }
    }
    cachedServiceDays = serviceDays;
    cachedRaptorData = pruned;
    return pruned;
  }
  public boolean equals(Object entry) {
    FunctionEntry newEntry = (FunctionEntry) entry;

    if (entry instanceof FunctionEntry
        && functionName.equals(newEntry.functionName())
        && numParameters == newEntry.numParameters()
        && parameters.equals(parameters)) return true;
    else return false;
  }
Example #26
0
 /** @see java.lang.Object#equals(java.lang.Object) */
 @Override
 public synchronized boolean equals(Object o) {
   if (!(o instanceof CachedList)) {
     return false;
   }
   @SuppressWarnings("rawtypes")
   CachedList that = (CachedList) o;
   return clazz.equals(that.clazz) && list.equals(that.list);
 }
 /** Sets the sorted list of filtered components. */
 public boolean setOrderedFilter(ArrayList<ComponentKey> f) {
   if (mSearchResults != f) {
     boolean same = mSearchResults != null && mSearchResults.equals(f);
     mSearchResults = f;
     updateAdapterItems();
     return !same;
   }
   return false;
 }
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   final TestCaseTemplateParameter other = (TestCaseTemplateParameter) obj;
   if (checkStateMethod == null) {
     if (other.checkStateMethod != null) return false;
   } else if (!checkStateMethod.equals(other.checkStateMethod)) return false;
   if (classUnderTest == null) {
     if (other.classUnderTest != null) return false;
   } else if (!classUnderTest.equals(other.classUnderTest)) return false;
   if (Double.doubleToLongBits(delta) != Double.doubleToLongBits(other.delta)) return false;
   if (hasDelta != other.hasDelta) return false;
   if (isStaticMethod != other.isStaticMethod) return false;
   if (methodUnderTest == null) {
     if (other.methodUnderTest != null) return false;
   } else if (!methodUnderTest.equals(other.methodUnderTest)) return false;
   if (packageName == null) {
     if (other.packageName != null) return false;
   } else if (!packageName.equals(other.packageName)) return false;
   if (returnType == null) {
     if (other.returnType != null) return false;
   } else if (!returnType.equals(other.returnType)) return false;
   if (singletonMethod == null) {
     if (other.singletonMethod != null) return false;
   } else if (!singletonMethod.equals(other.singletonMethod)) return false;
   if (this.constructorArguments == null) {
     if (other.constructorArguments != null) return false;
   } else if (!constructorArguments.equals(other.constructorArguments)) return false;
   if (this.methodParameters == null) {
     if (other.methodParameters != null) return false;
   } else if (!methodParameters.equals(other.methodParameters)) return false;
   if (this.imports == null) {
     if (other.imports != null) return false;
   } else if (!imports.equals(other.imports)) return false;
   if (this.classToMockInstanceNameMap == null) {
     if (other.classToMockInstanceNameMap != null) return false;
   } else if (!classToMockInstanceNameMap.equals(other.classToMockInstanceNameMap)) return false;
   if (this.jMockInvokeSequenceMap == null) {
     if (other.jMockInvokeSequenceMap != null) return false;
   } else if (!jMockInvokeSequenceMap.equals(other.jMockInvokeSequenceMap)) return false;
   return true;
 }
Example #29
-1
  /**
   * Generates a synthetic network for provided vertices in the given graphh such that the provided
   * expected number of communities are generated with the specified expected number of edges.
   *
   * @param graph
   * @param vertices
   * @param expectedNumCommunities
   * @param expectedNumEdges
   * @return The actual number of edges generated. May be different from the expected number.
   */
  public int generate(
      Graph graph, Iterable<Vertex> vertices, int expectedNumCommunities, int expectedNumEdges) {
    if (communitySize == null)
      throw new IllegalStateException("Need to initialize community size distribution");
    if (edgeDegree == null)
      throw new IllegalStateException("Need to initialize degree distribution");
    int numVertices = SizableIterable.sizeOf(vertices);
    Iterator<Vertex> iter = vertices.iterator();
    ArrayList<ArrayList<Vertex>> communities =
        new ArrayList<ArrayList<Vertex>>(expectedNumCommunities);
    Distribution communityDist = communitySize.initialize(expectedNumCommunities, numVertices);
    while (iter.hasNext()) {
      int nextSize = communityDist.nextValue(random);
      ArrayList<Vertex> community = new ArrayList<Vertex>(nextSize);
      for (int i = 0; i < nextSize && iter.hasNext(); i++) {
        community.add(iter.next());
      }
      if (!community.isEmpty()) communities.add(community);
    }

    double inCommunityPercentage = 1.0 - crossCommunityPercentage;
    Distribution degreeDist = edgeDegree.initialize(numVertices, expectedNumEdges);
    if (crossCommunityPercentage > 0 && communities.size() < 2)
      throw new IllegalArgumentException("Cannot have cross links with only one community");
    int addedEdges = 0;

    // System.out.println("Generating links on communities: "+communities.size());

    for (ArrayList<Vertex> community : communities) {
      for (Vertex v : community) {
        int degree = degreeDist.nextValue(random);
        degree =
            Math.min(degree, (int) Math.ceil((community.size() - 1) / inCommunityPercentage) - 1);
        Set<Vertex> inlinks = new HashSet<Vertex>();
        for (int i = 0; i < degree; i++) {
          Vertex selected = null;
          if (random.nextDouble() < crossCommunityPercentage
              || (community.size() - 1 <= inlinks.size())) {
            // Cross community
            ArrayList<Vertex> othercomm = null;
            while (othercomm == null) {
              othercomm = communities.get(random.nextInt(communities.size()));
              if (othercomm.equals(community)) othercomm = null;
            }
            selected = othercomm.get(random.nextInt(othercomm.size()));
          } else {
            // In community
            while (selected == null) {
              selected = community.get(random.nextInt(community.size()));
              if (v.equals(selected) || inlinks.contains(selected)) selected = null;
            }
            inlinks.add(selected);
          }
          addEdge(graph, v, selected);
          addedEdges++;
        }
      }
    }
    return addedEdges;
  }
Example #30
-1
 public boolean permutation(String s1, String s2) {
   if (s1.length() != s2.length()) return false;
   ArrayList<Character> a1 = compute(s1);
   ArrayList<Character> a2 = compute(s2);
   if (a1.equals(a2)) return true;
   return false;
 }