001 /*
002 * LAPIS lightweight structured text processing system
003 *
004 * Copyright (C) 1998-2002 Carnegie Mellon University,
005 * Copyright (C) 2003 Massachusetts Institute of Technology.
006 * All rights reserved.
007 *
008 * This library is free software; you can redistribute it
009 * and/or modify it under the terms of the GNU General
010 * Public License as published by the Free Software
011 * Foundation, version 2.
012 *
013 * LAPIS homepage: http://graphics.lcs.mit.edu/lapis/
014 */
015
016 package lapisx.sort;
017
018 import java.util.Vector;
019
020 public class SortableVector implements Sortable {
021 protected Vector v;
022
023 public SortableVector (Vector v) {
024 this.v = v;
025 }
026
027 public Object get (int i) {
028 return v.elementAt (i);
029 }
030
031 public void set (int i, Object o) {
032 v.setElementAt (o, i);
033 }
034
035 public int size () {
036 return v.size ();
037 }
038
039 public void swap (int i, int j) {
040 Object tmp = v.elementAt (i);
041 v.setElementAt (v.elementAt (j), i);
042 v.setElementAt (tmp, j);
043 }
044
045 public int compare (Object o1, Object o2) {
046 return o1.toString().compareTo (o2.toString ());
047 }
048 }