efficient circular buffer?

I would use collections.deque with a maxlen arg >>> import collections >>> d = collections.deque(maxlen=10) >>> d deque([], maxlen=10) >>> for i in xrange(20): … d.append(i) … >>> d deque([10, 11, 12, 13, 14, 15, 16, 17, 18, 19], maxlen=10) There is a recipe in the docs for deque that is similar to what you … Read more

How to create a closed (circular) ListView?

My colleague Joe, and I believe we have found a simpler way to solve the same problem. In our solution though instead of extending BaseAdapter we extend ArrayAdapter. The code is as follows : public class CircularArrayAdapter< T > extends ArrayAdapter< T > { public static final int HALF_MAX_VALUE = Integer.MAX_VALUE/2; public final int MIDDLE; … Read more

tech