Example usage for java.util Vector addAll

List of usage examples for java.util Vector addAll

Introduction

In this page you can find the example usage for java.util Vector addAll.

Prototype

public synchronized boolean addAll(int index, Collection<? extends E> c) 

Source Link

Document

Inserts all of the elements in the specified Collection into this Vector at the specified position.

Usage

From source file:Main.java

public static void main(String[] args) {
    Vector<Integer> firstvec = new Vector<Integer>(4);
    Vector<Integer> secondvec = new Vector<Integer>(4);

    // use add() method to add elements in the secondvec vector
    secondvec.add(5);/*from  w w w.ja  v a  2 s. c o m*/
    secondvec.add(6);
    secondvec.add(7);
    secondvec.add(8);

    // use add() method to add elements in the firstvec vector
    firstvec.add(1);
    firstvec.add(2);
    firstvec.add(3);
    firstvec.add(4);

    /** use addAll() method to add elements of the 2nd vector at 
    1st element position of the first vector */

    firstvec.addAll(1, secondvec);

    System.out.println(firstvec);

}

From source file:com.apache.fastandroid.novel.view.readview.PageFactory.java

/**
 * //w  w  w .j  a  v a2s  . co m
 */
private void pageUp() {
    String strParagraph = "";
    Vector<String> lines = new Vector<>(); // ?
    int paraSpace = 0;
    mPageLineCount = mVisibleHeight / (mFontSize + mLineSpace);
    while ((lines.size() < mPageLineCount) && (curBeginPos > 0)) {
        Vector<String> paraLines = new Vector<>(); // ?
        byte[] parabuffer = readParagraphBack(curBeginPos); // 1.??

        curBeginPos -= parabuffer.length; // 2.???
        try {
            strParagraph = new String(parabuffer, charset);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        strParagraph = strParagraph.replaceAll("\r\n", "  ");
        strParagraph = strParagraph.replaceAll("\n", " ");

        while (strParagraph.length() > 0) { // 3.?lines
            int paintSize = mPaint.breakText(strParagraph, true, mVisibleWidth, null);
            paraLines.add(strParagraph.substring(0, paintSize));
            strParagraph = strParagraph.substring(paintSize);
        }
        lines.addAll(0, paraLines);

        while (lines.size() > mPageLineCount) { // 4.??
            try {
                curBeginPos += lines.get(0).getBytes(charset).length; // 5.???????
                lines.remove(0);
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        }
        curEndPos = curBeginPos; // 6.???
        paraSpace += mLineSpace;
        mPageLineCount = (mVisibleHeight - paraSpace) / (mFontSize + mLineSpace); // ??
    }
}