Provide the standard Groovy <code>size()</code> method for <code>Iterator</code>.
The iterator will become exhausted of elements after determining the size value.

@param self an Iterator
@return the length of the Iterator
@since 1.5.5
329736
public static int size(Iterator self) {
        int count = 0;
        while (self.hasNext()) {
            self.next();
            count++;
        }
        return count;
    }
243596
@Override
    public int size() {
        // Try a few times to get accurate count. On failure due to
        // continuous async changes in table, resort to locking.
        final Segment<K,V>[] segments = this.segments;
        int size;
        boolean overflow; // true if size overflows 32 bits
        long sum;         // sum of modCounts
        long last = 0L;   // previous sum
        int retries = -1; // first iteration isn't retry
        try {
            for (;;) {
                if (retries++ == RETRIES_BEFORE_LOCK) {
                    for (int j = 0; j < segments.length; ++j)
                     {
                      ensureSegment(j).lock(); // force creation
                    }
                }
                sum = 0L;
                size = 0;
                overflow = false;
                for (int j = 0; j < segments.length; ++j) {
                    Segment<K,V> seg = segmentAt(segments, j);
                    if (seg != null) {
                        sum += seg.modCount;
                        int c = seg.count;
                        if (c < 0 || (size += c) < 0) {
                          overflow = true;
                        }
                    }
                }
                if (sum == last) {
                  break;
                }
                last = sum;
            }
        } finally {
            if (retries > RETRIES_BEFORE_LOCK) {
                for (int j = 0; j < segments.length; ++j) {
                  segmentAt(segments, j).unlock();
                }
            }
        }
        return overflow ? Integer.MAX_VALUE : size;
    }
906285
public long sizeOf()
    {
        return INSTANCE_SIZE + SizeOf.sizeOf(key) + SizeOf.sizeOf(value) + SizeOf.sizeOf(used);
    }
335474
public static int size(Object list) {
        if (list == null)
            return 0;
        if (list instanceof List)
            return ((List<?>) list).size();
        return 1;
    }
34026
final int getMinLength() {
		switch (this.type) {
		case CONCAT:
			int sum = 0;
			for (int i = 0; i < this.size(); i++)
				sum += this.getChild(i).getMinLength();
			return sum;

		case CONDITION:
		case UNION:
			if (this.size() == 0)
				return 0;
			int ret = this.getChild(0).getMinLength();
			for (int i = 1; i < this.size(); i++) {
				int min = this.getChild(i).getMinLength();
				if (min < ret)
					ret = min;
			}
			return ret;

		case CLOSURE:
		case NONGREEDYCLOSURE:
			if (this.getMin() >= 0)
				return this.getMin() * this.getChild(0).getMinLength();
			return 0;

		case EMPTY:
		case ANCHOR:
			return 0;

		case DOT:
		case CHAR:
		case RANGE:
		case NRANGE:
			return 1;

		case INDEPENDENT:
		case PAREN:
		case MODIFIERGROUP:
			return this.getChild(0).getMinLength();

		case BACKREFERENCE:
			return 0; // *******

		case STRING:
			return this.getString().length();

		case LOOKAHEAD:
		case NEGATIVELOOKAHEAD:
		case LOOKBEHIND:
		case NEGATIVELOOKBEHIND:
			return 0; // ***** Really?

		default:
			throw new RuntimeException("Token#getMinLength(): Invalid Type: "
					+ this.type);
		}
	}
547218
@Override
	public int size()
	{
		if (indics != null)
		{
			return indics.size();
		}

		indics = new HashMap<Integer, Pair<Integer, Integer>>();

		int size = 0;
		TestSequence rtests = repeat.getTests();
		int count = rtests.size();
		for (int r = from; r <= to; r++)
		{
			if (r == 0)
			{

				indics.put(size, new Pair<Integer, Integer>(r, 0));
				size++;
				continue;
			}

			int[] c = new int[r];

			for (int i = 0; i < r; i++)
			{
				c[i] = count;
			}

			Permutor p = new Permutor(c);

			int j = 0;
			while (p.hasNext())
			{
				j++;
				p.next();
				indics.put(size, new Pair<Integer, Integer>(r, j));
				size++;
			}
		}
		return size;
	}
985716
public long getSize() {
        long elementSize = dumpClass.getHprof().getValueSize(getType());

        return dumpClass.classDumpSegment.getMinimumInstanceSize() + HPROF_ARRAY_OVERHEAD + (elementSize * getLength());
    }
356407
public static Iterator iterator(final DefaultTableModel self) {
        return new Iterator() {
            private int row = 0;

            public boolean hasNext() {
                return row > -1 && row < self.getRowCount();
            }

            public Object next() {
                int cols = self.getColumnCount();
                Object[] rowData = new Object[cols];
                for (int col = 0; col < cols; col++) {
                    rowData[col] = self.getValueAt(row, col);
                }
                row++;
                return rowData;
            }

            public void remove() {
                if (hasNext()) self.removeRow(row--);
            }
        };
    }
138396
@Override
    public int size() {
	final Segment<K, V>[] segments = this.segments;
	long sum = 0;
	long check = 0;
	int[] mc = new int[segments.length];
	// Try a few times to get accurate count. On failure due to
	// continuous async changes in table, resort to locking.
	for (int k = 0; k < RETRIES_BEFORE_LOCK; ++k) {
	    check = 0;
	    sum = 0;
	    int mcsum = 0;
	    for (int i = 0; i < segments.length; ++i) {
		sum += segments[i].count;
		mcsum += mc[i] = segments[i].modCount;
	    }
	    if (mcsum != 0) {
		for (int i = 0; i < segments.length; ++i) {
		    check += segments[i].count;
		    if (mc[i] != segments[i].modCount) {
			check = -1; // force retry
			break;
		    }
		}
	    }
	    if (check == sum) break;
	}
	if (check != sum) { // Resort to locking all segments
	    sum = 0;
	    for (int i = 0; i < segments.length; ++i)
		segments[i].lock();
	    for (int i = 0; i < segments.length; ++i)
		sum += segments[i].count;
	    for (int i = 0; i < segments.length; ++i)
		segments[i].unlock();
	}
	if (sum > Integer.MAX_VALUE) return Integer.MAX_VALUE;
	return (int) sum;
    }
256067
public int size() {
        int read = readLocation;
        int write = writeLocation;

        if (write < read)
            write += capacity;

        return write - read;

    }
228736
public int getLength() {
        if (m_last == -1) {
            int node;
            while ((node = m_iter.next()) != DTMAxisIterator.END) {
                m_cachedNodes.addElement(node);
            }
            m_last = m_cachedNodes.size();
        }
        return m_last;
    }
767089
@Override
	public int size() {
		Long longSize = 0L;
		try {
			longSize = new Long(redisManager.dbSize(keySerializer.serialize(this.keyPrefix + "*")));
		} catch (SerializationException e) {
			logger.error("get keys error", e);
		}
		return longSize.intValue();
	}
988105
public synchronized int getSize() {
        try {
            ByteArrayOutputStream bOut = new ByteArrayOutputStream();
            ObjectOutputStream oOut = new ObjectOutputStream(bOut);
            oOut.writeObject(historyStore);
            bOut.close();
            return bOut.size();
        } catch (IOException e) {
            throw new IllegalStateException("Cannot serialize internal store: " + e,e);
        }
    }
467999
public int size() {
		Record record = client.operate(this.policy, this.key, ListOperation.size(this.binNameString));
		if (record != null) {
			return record.getInt(this.binNameString);
		}
		return 0;
	}
945037
@Override
    public int size () {
        int size = Smb2Constants.SMB2_HEADER_LENGTH + 56;
        int nameLen = 2 * this.name.length();
        if ( nameLen == 0 ) {
            nameLen++;
        }

        size += size8(nameLen);
        if ( this.createContexts != null ) {
            for ( CreateContextRequest ccr : this.createContexts ) {
                size += size8(ccr.size());
            }
        }
        return size8(size);
    }
50528
public int length() {
        if (tc.isEntryEnabled())
            SibTr.entry(tc, "length");
        if (tc.isDebugEnabled())
            SibTr.debug(tc, "rc=", elements);
        if (tc.isEntryEnabled())
            SibTr.exit(tc, "length");

        return elements;
    }
995899
public int getSize() {
		InnerList iList = ref.get();
		return iList != null ? iList.getList().size() : 0;
	}