use of de.lmu.ifi.dbs.elki.database.ids.DBIDArrayMIter in project elki by elki-project.
the class PROCLUS method computeM_current.
/**
* Computes the set of medoids in current iteration.
*
* @param m the medoids
* @param m_best the best set of medoids found so far
* @param m_bad the bad medoids
* @param random random number generator
* @return m_current, the set of medoids in current iteration
*/
private ArrayDBIDs computeM_current(DBIDs m, DBIDs m_best, DBIDs m_bad, Random random) {
ArrayModifiableDBIDs m_list = DBIDUtil.newArray(m);
m_list.removeDBIDs(m_best);
DBIDArrayMIter it = m_list.iter();
ArrayModifiableDBIDs m_current = DBIDUtil.newArray();
for (DBIDIter iter = m_best.iter(); iter.valid(); iter.advance()) {
if (m_bad.contains(iter)) {
int currentSize = m_current.size();
while (m_current.size() == currentSize) {
m_current.add(it.seek(random.nextInt(m_list.size())));
it.remove();
}
} else {
m_current.add(iter);
}
}
return m_current;
}
Aggregations