FileDocCategorySizeDatePackage
StringVector.javaAPI DocJava SE 6 API4524Tue Jun 10 00:23:10 BST 2008com.sun.org.apache.xml.internal.utils

StringVector

public class StringVector extends Object implements Serializable
A very simple table that stores a list of strings, optimized for small lists.
xsl.usage
internal

Fields Summary
static final long
serialVersionUID
protected int
m_blocksize
protected String[]
m_map
protected int
m_firstFree
protected int
m_mapSize
Constructors Summary
public StringVector()
Default constructor. Note that the default block size is very small, for small lists.


                    
   
  

    m_blocksize = 8;
    m_mapSize = m_blocksize;
    m_map = new String[m_blocksize];
  
public StringVector(int blocksize)
Construct a StringVector, using the given block size.

param
blocksize Size of the blocks to allocate


    m_blocksize = blocksize;
    m_mapSize = blocksize;
    m_map = new String[blocksize];
  
Methods Summary
public final voidaddElement(java.lang.String value)
Append a string onto the vector.

param
value Sting to add to the vector


    if ((m_firstFree + 1) >= m_mapSize)
    {
      m_mapSize += m_blocksize;

      String newMap[] = new String[m_mapSize];

      System.arraycopy(m_map, 0, newMap, 0, m_firstFree + 1);

      m_map = newMap;
    }

    m_map[m_firstFree] = value;

    m_firstFree++;
  
public final booleancontains(java.lang.String s)
Tell if the table contains the given string.

param
s String to look for
return
True if the string is in this table


    if (null == s)
      return false;

    for (int i = 0; i < m_firstFree; i++)
    {
      if (m_map[i].equals(s))
        return true;
    }

    return false;
  
public final booleancontainsIgnoreCase(java.lang.String s)
Tell if the table contains the given string. Ignore case.

param
s String to find
return
True if the String is in this vector


    if (null == s)
      return false;

    for (int i = 0; i < m_firstFree; i++)
    {
      if (m_map[i].equalsIgnoreCase(s))
        return true;
    }

    return false;
  
public final java.lang.StringelementAt(int i)
Get the nth element.

param
i Index of string to find
return
String at given index

    return m_map[i];
  
public intgetLength()
Get the length of the list.

return
Number of strings in the list

    return m_firstFree;
  
public final java.lang.Stringpeek()
Get the string at the tail of this vector without popping.

return
The string at the tail of this vector.

    return (m_firstFree <= 0) ? null : m_map[m_firstFree - 1];
  
public final java.lang.Stringpop()
Pop the tail of this vector.

return
The String last added to this vector or null not found. The string is removed from the vector.


    if (m_firstFree <= 0)
      return null;

    m_firstFree--;

    String s = m_map[m_firstFree];

    m_map[m_firstFree] = null;

    return s;
  
public final voidpush(java.lang.String s)
Tell if the table contains the given string.

param
s String to push into the vector


    if ((m_firstFree + 1) >= m_mapSize)
    {
      m_mapSize += m_blocksize;

      String newMap[] = new String[m_mapSize];

      System.arraycopy(m_map, 0, newMap, 0, m_firstFree + 1);

      m_map = newMap;
    }

    m_map[m_firstFree] = s;

    m_firstFree++;
  
public final intsize()
Get the length of the list.

return
Number of strings in the list

    return m_firstFree;