本文整理匯總了Java中java.util.Vector.lastElement方法的典型用法代碼示例。如果您正苦於以下問題:Java Vector.lastElement方法的具體用法?Java Vector.lastElement怎麽用?Java Vector.lastElement使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.Vector
的用法示例。
在下文中一共展示了Vector.lastElement方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: sameTriangle
import java.util.Vector; //導入方法依賴的package包/類
/**
* Tests whether two triangles are the same. Order of vertices is ignored.
*
* @param t1, t2 The triangles to compare
*/
public static boolean sameTriangle(Triangle t1, Triangle t2) {
if (t1 == t2) {
return true;
}
Vector<Vertex> v1 = t1.getVertices();
Vector<Vertex> v2 = t2.getVertices();
if (v1 == v2) {
return true;
}
Vertex t1A = v1.firstElement();
Vertex t1B = v1.elementAt(1);
Vertex t1C = v1.lastElement();
Vertex t2A = v2.firstElement();
Vertex t2B = v2.elementAt(1);
Vertex t2C = v2.lastElement();
return (Vertex.sameVertex(t1A, t2A) || Vertex.sameVertex(t1A, t2B) || Vertex.sameVertex(t1A, t2C))
&& (Vertex.sameVertex(t1B, t2A) || Vertex.sameVertex(t1B, t2B) || Vertex.sameVertex(t1B, t2C))
&& (Vertex.sameVertex(t1C, t2A) || Vertex.sameVertex(t1C, t2B) || Vertex.sameVertex(t1C, t2C));
}
示例2: interSetFaces
import java.util.Vector; //導入方法依賴的package包/類
/**
* Determine the hull faces that have vertices in each of two sets
*
* @param - s1, s2 the vertex sets
* @return - returns a vector of triangles that lie on the hull
*/
public Vector<Triangle> interSetFaces(Vector s1, Vector s2) {
Vector<Polygon> faces = getFaces();
Vector<Triangle> xFaces = new Vector<Triangle>();
for (Polygon polygon : faces) {
Triangle t = (Triangle) polygon;
Vector<Vertex> v = t.getVertices();
Vertex v1 = v.firstElement();
Vertex v2 = v.elementAt(1);
Vertex v3 = v.lastElement();
if ((s1.contains(v1) || s1.contains(v2) || s1.contains(v3)) && (s2.contains(v1) || s2.contains(v2) || s2.contains(v3))) {
xFaces.addElement(t);
}
}
return xFaces;
}
示例3: RemoveCollinear
import java.util.Vector; //導入方法依賴的package包/類
public Vector<newPoint> RemoveCollinear(Vector<newPoint> vertices) {
Vector<newPoint> out = new Vector<newPoint>(vertices);
int ilast = vertices.size() - 1;
newPoint first = out.get(0);
// Attenzione qui sotto out.get(0) -> out.get(1) ??
newPoint second = out.get(1);
newPoint last = out.lastElement();
newPoint prelast = out.get(ilast - 1);
if (last.x == prelast.x && last.y == 0) {
out.remove(out.lastElement());
}
if (first.y == second.y && first.x == 0) {
out.removeElementAt(0);
}
return out;
}
示例4: valueOf
import java.util.Vector; //導入方法依賴的package包/類
/** Evaluate the value of an integer polynomial at some integer argument.
* @param c Represents the coefficients c[0]+c[1]*x+c[2]*x^2+.. of the polynomial
* @param x The abscissa point of the evaluation
* @return The polynomial value.
* @since 2010-08-27
* @author Richard J. Mathar
*/
static public BigInteger valueOf(final Vector<BigInteger>c, final BigInteger x)
{
if (c.size() == 0)
return BigInteger.ZERO ;
BigInteger res = c.lastElement() ;
for(int i= c.size()-2 ; i >=0 ; i--)
res = res.multiply(x).add( c.elementAt(i) ) ;
return res ;
}
示例5: item
import java.util.Vector; //導入方法依賴的package包/類
/** Returns the node at the specified index. */
public Node item(int index) {
Node thisNode;
// Tree changed. Do it all from scratch!
if(rootNode.changes() != changes) {
nodes = new Vector();
changes = rootNode.changes();
}
// In the cache
if (index < nodes.size())
return (Node)nodes.elementAt(index);
// Not yet seen
else {
// Pick up where we left off (Which may be the beginning)
if (nodes.size() == 0)
thisNode = rootNode;
else
thisNode=(NodeImpl)(nodes.lastElement());
// Add nodes up to the one we're looking for
while(thisNode != null && index >= nodes.size()) {
thisNode=nextMatchingElementAfter(thisNode);
if (thisNode != null)
nodes.addElement(thisNode);
}
// Either what we want, or null (not avail.)
return thisNode;
}
}
示例6: main
import java.util.Vector; //導入方法依賴的package包/類
public static void main(String... args) throws IOException {
Vector s = new Vector();
if (args == null)
s.lastElement();
else
s.elementAt(0);
}
示例7: doBack
import java.util.Vector; //導入方法依賴的package包/類
public static boolean doBack(HttpServletRequest request, HttpServletResponse response) throws IOException {
synchronized (request.getSession()) {
String uri = request.getParameter("uri");
Vector back = getBackList(request.getSession());
if (back.isEmpty()) {
if (uri != null) {
response.sendRedirect(response.encodeURL(uri));
return true;
}
return false;
}
if (uri==null) {
uri = ((String[])back.lastElement())[0];
back.remove(back.size()-1);
} else {
String uriNoBack = uri;
if (uriNoBack.indexOf("backType=")>=0)
uriNoBack = uriNoBack.substring(0, uriNoBack.indexOf("backType=")-1);
while (!back.isEmpty() && !uriNoBack.equals(((String[])back.lastElement())[0]))
back.remove(back.size()-1);
if (!back.isEmpty())
back.remove(back.size()-1);
}
if (uri.indexOf("backType=")<0 && request.getAttribute("backType")!=null && request.getAttribute("backId")!=null) {
if (uri.indexOf('?')>0)
uri += "&backType="+request.getAttribute("backType")+"&backId="+request.getAttribute("backId")+"#back";
else
uri += "?backType="+request.getAttribute("backType")+"&backId="+request.getAttribute("backId")+"#back";
}
response.sendRedirect(response.encodeURL(uri));
return true;
}
}
示例8: getOption
import java.util.Vector; //導入方法依賴的package包/類
private Vector<String> getOption(String option, int minarg, int maxarg) throws ConfigParseError {
Vector<Vector<String>> alloptions = getAllOption(option, minarg, maxarg);
if (alloptions == null) return null;
else return alloptions.lastElement();
}
示例9: nextContractChar
import java.util.Vector; //導入方法依賴的package包/類
/**
* Get the ordering priority of the next contracting character in the
* string.
* @param ch the starting character of a contracting character token
* @return the next contracting character's ordering. Returns NULLORDER
* if the end of string is reached.
*/
private int nextContractChar(int ch)
{
// First get the ordering of this single character,
// which is always the first element in the list
Vector<EntryPair> list = ordering.getContractValues(ch);
EntryPair pair = list.firstElement();
int order = pair.value;
// find out the length of the longest contracting character sequence in the list.
// There's logic in the builder code to make sure the longest sequence is always
// the last.
pair = list.lastElement();
int maxLength = pair.entryName.length();
// (the Normalizer is cloned here so that the seeking we do in the next loop
// won't affect our real position in the text)
NormalizerBase tempText = (NormalizerBase)text.clone();
// extract the next maxLength characters in the string (we have to do this using the
// Normalizer to ensure that our offsets correspond to those the rest of the
// iterator is using) and store it in "fragment".
tempText.previous();
key.setLength(0);
int c = tempText.next();
while (maxLength > 0 && c != NormalizerBase.DONE) {
if (Character.isSupplementaryCodePoint(c)) {
key.append(Character.toChars(c));
maxLength -= 2;
} else {
key.append((char)c);
--maxLength;
}
c = tempText.next();
}
String fragment = key.toString();
// now that we have that fragment, iterate through this list looking for the
// longest sequence that matches the characters in the actual text. (maxLength
// is used here to keep track of the length of the longest sequence)
// Upon exit from this loop, maxLength will contain the length of the matching
// sequence and order will contain the collation-element value corresponding
// to this sequence
maxLength = 1;
for (int i = list.size() - 1; i > 0; i--) {
pair = list.elementAt(i);
if (!pair.fwd)
continue;
if (fragment.startsWith(pair.entryName) && pair.entryName.length()
> maxLength) {
maxLength = pair.entryName.length();
order = pair.value;
}
}
// seek our current iteration position to the end of the matching sequence
// and return the appropriate collation-element value (if there was no matching
// sequence, we're already seeked to the right position and order already contains
// the correct collation-element value for the single character)
while (maxLength > 1) {
c = text.next();
maxLength -= Character.charCount(c);
}
return order;
}
示例10: prevContractChar
import java.util.Vector; //導入方法依賴的package包/類
/**
* Get the ordering priority of the previous contracting character in the
* string.
* @param ch the starting character of a contracting character token
* @return the next contracting character's ordering. Returns NULLORDER
* if the end of string is reached.
*/
private int prevContractChar(int ch)
{
// This function is identical to nextContractChar(), except that we've
// switched things so that the next() and previous() calls on the Normalizer
// are switched and so that we skip entry pairs with the fwd flag turned on
// rather than off. Notice that we still use append() and startsWith() when
// working on the fragment. This is because the entry pairs that are used
// in reverse iteration have their names reversed already.
Vector<EntryPair> list = ordering.getContractValues(ch);
EntryPair pair = list.firstElement();
int order = pair.value;
pair = list.lastElement();
int maxLength = pair.entryName.length();
NormalizerBase tempText = (NormalizerBase)text.clone();
tempText.next();
key.setLength(0);
int c = tempText.previous();
while (maxLength > 0 && c != NormalizerBase.DONE) {
if (Character.isSupplementaryCodePoint(c)) {
key.append(Character.toChars(c));
maxLength -= 2;
} else {
key.append((char)c);
--maxLength;
}
c = tempText.previous();
}
String fragment = key.toString();
maxLength = 1;
for (int i = list.size() - 1; i > 0; i--) {
pair = list.elementAt(i);
if (pair.fwd)
continue;
if (fragment.startsWith(pair.entryName) && pair.entryName.length()
> maxLength) {
maxLength = pair.entryName.length();
order = pair.value;
}
}
while (maxLength > 1) {
c = text.previous();
maxLength -= Character.charCount(c);
}
return order;
}
示例11: prioritizeRules
import java.util.Vector; //導入方法依賴的package包/類
/**
* Orders a set or rules by priority, removes redundant rules and rules
* that are shadowed by stronger, contradicting rules.
*/
private static int prioritizeRules(Vector rules) {
WhitespaceRule currentRule;
int defaultAction = PRESERVE_SPACE;
// Sort all rules with regard to priority
quicksort(rules, 0, rules.size()-1);
// Check if there are any "xsl:strip-space" elements at all.
// If there are no xsl:strip elements we can ignore all xsl:preserve
// elements and signal that all whitespaces should be preserved
boolean strip = false;
for (int i = 0; i < rules.size(); i++) {
currentRule = (WhitespaceRule)rules.elementAt(i);
if (currentRule.getAction() == STRIP_SPACE) {
strip = true;
}
}
// Return with default action: PRESERVE_SPACE
if (!strip) {
rules.removeAllElements();
return PRESERVE_SPACE;
}
// Remove all rules that are contradicted by rules with higher priority
for (int idx = 0; idx < rules.size(); ) {
currentRule = (WhitespaceRule)rules.elementAt(idx);
// Remove this single rule if it has no purpose
if (findContradictingRule(rules,currentRule) != null) {
rules.remove(idx);
}
else {
// Remove all following rules if this one overrides all
if (currentRule.getStrength() == RULE_ALL) {
defaultAction = currentRule.getAction();
for (int i = idx; i < rules.size(); i++) {
rules.removeElementAt(i);
}
}
// Skip to next rule (there might not be any)...
idx++;
}
}
// The rules vector could be empty if first rule has strength RULE_ALL
if (rules.size() == 0) {
return defaultAction;
}
// Now work backwards and strip away all rules that have the same
// action as the default rule (no reason the check them at the end).
do {
currentRule = (WhitespaceRule)rules.lastElement();
if (currentRule.getAction() == defaultAction) {
rules.removeElementAt(rules.size() - 1);
}
else {
break;
}
} while (rules.size() > 0);
// Signal that whitespace detection predicate must be used.
return defaultAction;
}
示例12: main
import java.util.Vector; //導入方法依賴的package包/類
public static void main(String... args) throws IOException {
Vector s = new Vector();
s.lastElement();
s.elementAt(0);
}
示例13: get
import java.util.Vector; //導入方法依賴的package包/類
/**
* Gets the last-defined string value for the specified keys.
* @param keys the keys, as an array from section name, sub-section names
* (if any), to value name.
* @return the value. When there are multiple values for the same key,
* returns the last one. {@code null} is returned if not all the keys are
* defined. For example, {@code get("libdefaults", "forwardable")} will
* return null if "forwardable" is not defined in [libdefaults], and
* {@code get("realms", "R", "kdc")} will return null if "R" is not
* defined in [realms] or "kdc" is not defined for "R".
* @throws IllegalArgumentException if any of the keys is illegal, either
* because a key not the last one is not a (sub)section name or the last
* key is still a section name. For example, {@code get("libdefaults")}
* throws this exception because [libdefaults] is a section name instead of
* a value name, and {@code get("libdefaults", "forwardable", "tail")}
* also throws this exception because "forwardable" is already a value name
* and has no sub-key at all (given "forwardable" is defined, otherwise,
* this method has no knowledge if it's a value name or a section name),
*/
public String get(String... keys) {
Vector<String> v = getString0(keys);
if (v == null) return null;
return v.lastElement();
}