List of usage examples for java.util Vector trimToSize
public synchronized void trimToSize()
From source file:org.apache.usergrid.apm.util.GenerateSimulatedMobileData.java
public synchronized static void expireSessions(Vector<MobileSession> sessions, int numSessionsToExpire) { int currentNumberOfSessions = sessions.size(); System.out.println("Expiring " + numSessionsToExpire + " old sessions"); int index;//from ww w . j a v a2 s . c om for (int i = 0; i < numSessionsToExpire; i++) { index = generator.nextInt(currentNumberOfSessions - i); MobileSession s = sessions.get(index); Device d = s.getDevice(); d.setInUse(false); sessions.remove(index); s = null; } sessions.trimToSize(); }
From source file:org.apache.usergrid.apm.util.GenerateSimulatedMobileData.java
public synchronized static void addNewSessions(Vector<MobileSession> sessions, Vector<Device> devices, int numSessionToAdd) { int numDevices = devices.size(); int j = 0;//from w w w. j a v a 2 s . co m System.out.println("Adding " + numSessionToAdd + " new sessions"); Device d; while (j < numSessionToAdd) { d = devices.get(generator.nextInt(numDevices)); if (!d.isInUse()) { d.setInUse(true); MobileSession s = new MobileSession(); s.setDevice(d); sessions.add(s); j++; } } sessions.trimToSize(); }