Apparently the proper way to remove a range from a List is to call
subList(range).clear(); git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3012 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: SpeakProvider.java,v 1.20 2004/03/06 11:29:18 mdb Exp $
|
// $Id: SpeakProvider.java,v 1.21 2004/05/25 21:58:14 ray Exp $
|
||||||
|
|
||||||
package com.threerings.crowd.chat.server;
|
package com.threerings.crowd.chat.server;
|
||||||
|
|
||||||
@@ -280,7 +280,7 @@ public class SpeakProvider
|
|||||||
*/
|
*/
|
||||||
public static ArrayList getChatHistory (Name username)
|
public static ArrayList getChatHistory (Name username)
|
||||||
{
|
{
|
||||||
HistoryList history = getHistoryList(username);
|
ArrayList history = getHistoryList(username);
|
||||||
pruneHistory(System.currentTimeMillis(), history);
|
pruneHistory(System.currentTimeMillis(), history);
|
||||||
return history;
|
return history;
|
||||||
}
|
}
|
||||||
@@ -307,7 +307,7 @@ public class SpeakProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add the message to this user's chat history
|
// add the message to this user's chat history
|
||||||
HistoryList history = getHistoryList(username);
|
ArrayList history = getHistoryList(username);
|
||||||
history.add(msg);
|
history.add(msg);
|
||||||
|
|
||||||
// if the history is big enough, potentially prune it (we always
|
// if the history is big enough, potentially prune it (we always
|
||||||
@@ -326,11 +326,11 @@ public class SpeakProvider
|
|||||||
/**
|
/**
|
||||||
* Returns this user's chat history, creating one if necessary.
|
* Returns this user's chat history, creating one if necessary.
|
||||||
*/
|
*/
|
||||||
protected static HistoryList getHistoryList (Name username)
|
protected static ArrayList getHistoryList (Name username)
|
||||||
{
|
{
|
||||||
HistoryList history = (HistoryList)_histories.get(username);
|
ArrayList history = (ArrayList)_histories.get(username);
|
||||||
if (history == null) {
|
if (history == null) {
|
||||||
_histories.put(username, history = new HistoryList());
|
_histories.put(username, history = new ArrayList());
|
||||||
}
|
}
|
||||||
return history;
|
return history;
|
||||||
}
|
}
|
||||||
@@ -338,7 +338,7 @@ public class SpeakProvider
|
|||||||
/**
|
/**
|
||||||
* Prunes all messages from this history which are expired.
|
* Prunes all messages from this history which are expired.
|
||||||
*/
|
*/
|
||||||
protected static void pruneHistory (long now, HistoryList history)
|
protected static void pruneHistory (long now, ArrayList history)
|
||||||
{
|
{
|
||||||
int prunepos = 0;
|
int prunepos = 0;
|
||||||
for (int ll = history.size(); prunepos < ll; prunepos++) {
|
for (int ll = history.size(); prunepos < ll; prunepos++) {
|
||||||
@@ -347,7 +347,7 @@ public class SpeakProvider
|
|||||||
break; // stop when we get to the first valid message
|
break; // stop when we get to the first valid message
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
history.remove(0, prunepos);
|
history.subList(0, prunepos).clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Used to note the recipients of a chat message. */
|
/** Used to note the recipients of a chat message. */
|
||||||
@@ -367,15 +367,6 @@ public class SpeakProvider
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Extends {@link ArrayList} for the sole purpose of exposing {@link
|
|
||||||
* ArrayList#removeRange}. Yay! */
|
|
||||||
protected static class HistoryList extends ArrayList
|
|
||||||
{
|
|
||||||
public void remove (int fromIndex, int toIndex) {
|
|
||||||
removeRange(fromIndex, toIndex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Used to notify our {@link MessageObserver}s. */
|
/** Used to notify our {@link MessageObserver}s. */
|
||||||
protected static class MessageObserverOp implements ObserverList.ObserverOp
|
protected static class MessageObserverOp implements ObserverList.ObserverOp
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user