本文整理匯總了Java中java.util.AbstractCollection.iterator方法的典型用法代碼示例。如果您正苦於以下問題:Java AbstractCollection.iterator方法的具體用法?Java AbstractCollection.iterator怎麽用?Java AbstractCollection.iterator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.AbstractCollection
的用法示例。
在下文中一共展示了AbstractCollection.iterator方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: translate
import java.util.AbstractCollection; //導入方法依賴的package包/類
@Override
public Parameter[] translate(AbstractCollection<T> value) throws TranslationException {
Parameter[] parameters = new Parameter[value.size()];
int i = 0;
Iterator<T> it = value.iterator();
Translator translator = Translator.getInstance();
while (it.hasNext()) {
Parameter[] translation = translator.translate2Parameter(it.next());
if (translation.length == 1) {
// Translations into single parameters are unwrapped.
parameters[i] = translation[0];
} else {
parameters[i] = new ParameterList(translation);
}
i++;
}
return new Parameter[] { new ParameterList(parameters) };
}
示例2: join
import java.util.AbstractCollection; //導入方法依賴的package包/類
private static String join(AbstractCollection<String> col, String delimiter) {
if (col.isEmpty()) return "";
Iterator<String> iter = col.iterator();
StringBuffer buffer = new StringBuffer(iter.next());
while(iter.hasNext()) buffer.append(delimiter).append(iter.next());
return buffer.toString();
}
示例3: joinStr
import java.util.AbstractCollection; //導入方法依賴的package包/類
public <E> String joinStr(AbstractCollection<E> list, String delim) {
StringBuffer buf = new StringBuffer();
Iterator<E> iterator = list.iterator();
while (iterator.hasNext()) {
if (buf.length() != 0)
buf.append(delim);
buf.append(iterator.next().toString());
}
return buf.toString();
}
示例4: join
import java.util.AbstractCollection; //導入方法依賴的package包/類
public static String join(AbstractCollection<String> s, String delimiter) {
if (s.isEmpty()) return "";
Iterator<String> iter = s.iterator();
StringBuffer buffer = new StringBuffer(iter.next());
while (iter.hasNext()) {
buffer.append(delimiter);
buffer.append(iter.next());
}
return buffer.toString();
}
示例5: join
import java.util.AbstractCollection; //導入方法依賴的package包/類
/**
* Join multiple strings into a string delimited by the given delimiter.
*
* @param s a collection of strings
* @param delimiter the delimiter
* @return a 'delimiter' separated string
*/
public static String join(AbstractCollection<String> s, String delimiter) {
if (s.isEmpty()) return "";
Iterator<String> iter = s.iterator();
StringBuffer buffer = new StringBuffer(iter.next());
while (iter.hasNext()) {
buffer.append(delimiter);
buffer.append(iter.next());
}
return buffer.toString();
}
示例6: join
import java.util.AbstractCollection; //導入方法依賴的package包/類
public static String join(AbstractCollection<String> s, String delimiter) {
if (s == null || s.isEmpty())
return "";
Iterator<String> iter = s.iterator();
StringBuilder builder = new StringBuilder(iter.next());
while (iter.hasNext()) {
builder.append(delimiter).append(iter.next());
}
return builder.toString();
}