size() public method

public size ( ) : int
return int
	public static int test() {
		Set<Short> s = new HashSet<Short>();
		for (short i = 0; i < 100; i++) {
			s.add(i);
			s.remove(i - 1);
		}
		return s.size();
	}
Esempio n. 2
0
		public static bool moreInfo = false; // True iff more info in toString

		/**
		 * Constructor.
		 * @param collection a Collection holding the Simplex vertices
		 * @throws IllegalArgumentException if there are duplicate vertices
		 */
		public Simplex(Collection collection)
		{
			this.vertices = Collections.unmodifiableList(new java.util.ArrayList(collection));
			this.idNumber = idGenerator++;
			Set noDups = new HashSet(this);
			if (noDups.size() != this.vertices.size())
				throw new InvalidOperationException("Duplicate vertices in Simplex");
		}
		public TypeBuilder[] getDependencies() {
            checkCreated();
			var dependencies = new HashSet<TypeBuilder>();
			addType(dependencies, baseType);
			foreach (var t in interfaces) {
				addType(dependencies, t);
			}
            foreach (var a in annotations) {
				addType(dependencies, a.Type);
			}
            foreach (var nt in nestedTypes) {
				foreach (var t in ((TypeBuilder)nt).getDependencies()) {
					dependencies.add((TypeBuilder)t);
				}
			}
			foreach (var f in fields) {
				foreach (var a in f.Annotations) {
					addType(dependencies, a.Type);
				}
				addType(dependencies, f.Type);
			}
            foreach (var m in methods) {
                if (!m.IsExcludedFromCompilation) {
					foreach (var a in m.Annotations) {
						addType(dependencies, a.Type);
					}
					addType(dependencies, m.ReturnType);
					foreach (var p in m.Parameters) {
						foreach (var a in p.Annotations) {
							addType(dependencies, a.Type);
						}
						addType(dependencies, p.Type);
					}
					foreach (var e in m.Exceptions) {
						addType(dependencies, e);
					}
					foreach (var instruction in ((MethodBuilder)m).CodeGenerator.Instructions) {
						switch (instruction.Opcode) {
						case Getfield:
						case Getstatic:
						case Putfield:
						case Putstatic:
							addType(dependencies, instruction.Field.DeclaringType);
							break;
							
						case Invokedynamic:
						case Invokeinterface:
						case Invokespecial:
						case Invokestatic:
						case Invokevirtual:
							addType(dependencies, instruction.Method.DeclaringType);
							break;
						case Anewarray:
						case Checkcast:
						case Instanceof:
						case New:
							addType(dependencies, instruction.Type);
							break;
						}
					}
				}
			}
			return dependencies.toArray(new TypeBuilder[dependencies.size()]);
		}
Esempio n. 4
0
		/**
		 * True iff simplices are neighbors.
		 * Two simplices are neighbors if they are the same dimension and they share
		 * a facet.
		 * @param simplex the other Simplex
		 * @return true iff this Simplex is a neighbor of simplex
		 */
		public bool isNeighbor(Simplex simplex)
		{
			HashSet h = new HashSet(this);
			h.removeAll(simplex);
			return (this.size() == simplex.size()) && (h.size() == 1);
		}
 static TypeInfo getFixedType(Library typeSystem, Collection<TypeInfo> bounds) {
     var filteredBounds = new HashSet<TypeInfo>(bounds);
     foreach (var ti in bounds) {
         foreach (var tj in bounds) {
             if (!BytecodeHelper.hasImplicitConversion(ti, tj)) {
                 filteredBounds.remove(tj);
             }
         }
     }
     if (filteredBounds.size() != 1) {
         return null;
     } else {
         var result = filteredBounds.single();
         if (result == null) {
             return typeSystem.ObjectType;
         } else {
             return result;
         }
     }
 }