[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Patch: java.text.CollationElementIterator
From: |
Guilhem Lavaux |
Subject: |
Patch: java.text.CollationElementIterator |
Date: |
Thu, 15 Jul 2004 14:48:19 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040115 |
Hi,
I've just commited the attached patch to use ArrayList instead of Vector
in CollationElementIterator. There is no regression in
java/text/RuleBasedCollator and java/text/CollationElementIterator but
if you find one please notify it to me.
Guilhem.
2004-07-15 Guilhem Lavaux <address@hidden>
* java/text/CollationElementIterator.java
(text_decomposition): Changed type to
RuleBasedCollator.CollationElement[]
(setText): Use ArrayList instead of Vector.
Index: java/text/CollationElementIterator.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/text/CollationElementIterator.java,v
retrieving revision 1.18
diff -u -r1.18 CollationElementIterator.java
--- java/text/CollationElementIterator.java 30 May 2004 16:34:23 -0000
1.18
+++ java/text/CollationElementIterator.java 15 Jul 2004 12:46:57 -0000
@@ -38,7 +38,7 @@
package java.text;
-import java.util.Vector;
+import java.util.ArrayList;
/* Written using "Java Class Libraries", 2nd edition, plus online
* API docs for JDK 1.2 from http://www.javasoft.com.
@@ -89,7 +89,7 @@
* Array containing the collation decomposition of the
* text given to the constructor.
*/
- private Object[] text_decomposition;
+ private RuleBasedCollator.CollationElement[] text_decomposition;
/**
* Array containing the index of the specified block.
@@ -116,8 +116,7 @@
if (index >= text_decomposition.length)
return null;
- RuleBasedCollator.CollationElement e =
- (RuleBasedCollator.CollationElement) text_decomposition[index];
+ RuleBasedCollator.CollationElement e = text_decomposition[index];
textIndex = text_indexes[index+1];
@@ -132,8 +131,7 @@
return null;
index--;
- RuleBasedCollator.CollationElement e =
- (RuleBasedCollator.CollationElement) text_decomposition[index];
+ RuleBasedCollator.CollationElement e = text_decomposition[index];
textIndex = text_indexes[index+1];
@@ -247,8 +245,8 @@
String work_text = text.intern();
- Vector v = new Vector();
- Vector vi = new Vector();
+ ArrayList a_element = new ArrayList();
+ ArrayList a_idx = new ArrayList();
// Build element collection ordered as they come in "text".
while (idx < work_text.length())
@@ -301,8 +299,8 @@
RuleBasedCollator.CollationElement e =
collator.getDefaultAccentedElement (work_text.charAt (idx));
- v.add (e);
- vi.add (new Integer(idx_idx));
+ a_element.add (e);
+ a_idx.add (new Integer(idx_idx));
idx++;
alreadyExpanded--;
if (alreadyExpanded == 0)
@@ -326,10 +324,10 @@
/* Don't forget to mark it as a special sequence so the
* string can be ordered.
*/
- v.add (RuleBasedCollator.SPECIAL_UNKNOWN_SEQ);
- vi.add (i_ref);
- v.add (e);
- vi.add (i_ref);
+ a_element.add (RuleBasedCollator.SPECIAL_UNKNOWN_SEQ);
+ a_idx.add (i_ref);
+ a_element.add (e);
+ a_idx.add (i_ref);
idx_idx++;
idx++;
}
@@ -346,8 +344,8 @@
work_text = prefix.expansion
+ work_text.substring (idx+prefix.key.length());
idx = 0;
- v.add (prefix);
- vi.add (new Integer(idx_idx));
+ a_element.add (prefix);
+ a_idx.add (new Integer(idx_idx));
if (alreadyExpanded == 0)
idxToMove = prefix.key.length();
alreadyExpanded += prefix.expansion.length()-prefix.key.length();
@@ -357,8 +355,8 @@
/* Third case: the simplest. We have got the prefix and it
* has not to be expanded.
*/
- v.add (prefix);
- vi.add (new Integer(idx_idx));
+ a_element.add (prefix);
+ a_idx.add (new Integer(idx_idx));
idx += prefix.key.length();
/* If the sequence is in an expansion, we must decrease the
* counter.
@@ -376,13 +374,14 @@
}
}
- text_decomposition = v.toArray();
- text_indexes = new int[vi.size()+1];
- for (int i = 0; i < vi.size(); i++)
+ text_decomposition = (RuleBasedCollator.CollationElement[])
+ a_element.toArray(new
RuleBasedCollator.CollationElement[a_element.size()]);
+ text_indexes = new int[a_idx.size()+1];
+ for (int i = 0; i < a_idx.size(); i++)
{
- text_indexes[i] = ((Integer)vi.elementAt(i)).intValue();
+ text_indexes[i] = ((Integer)a_idx.get(i)).intValue();
}
- text_indexes[vi.size()] = text.length();
+ text_indexes[a_idx.size()] = text.length();
}
/**
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Patch: java.text.CollationElementIterator,
Guilhem Lavaux <=