Esempio n. 1
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// Build a new {@code FxMatrix} from the data in the builder.
 /// </summary>
 /// <returns> a new {@code FxMatrix} </returns>
 /// <exception cref="IllegalStateException"> if an attempt was made to add currencies
 ///   which have no currency in common with other rates </exception>
 public virtual FxMatrix build()
 {
     if (disjointRates.Count > 0)
     {
         throw new System.InvalidOperationException("Received rates with no currencies in common with other: " + disjointRates);
     }
     // Trim array down to the correct size - we have to copy the array
     // anyway to ensure immutability, so we may as well remove any
     // unused rows
     return(new FxMatrix(ImmutableMap.copyOf(currencies), DoubleMatrix.ofUnsafe(copyArray(rates, currencies.size()))));
 }
Esempio n. 2
0
 public LRUCache(int _size)
 {
     this._size = _size;
     map        = new LinkedHashMap <K, V>(_size * 4 / 3 + 1, 0.75f, true, () =>
     {
         return(map.size() > _size);
     });
 }
Esempio n. 3
0
        public virtual void addTexture(IRenderingEngine re, Texture texture)
        {
            int?    key             = getKey(texture.Addr, texture.ClutAddr, texture.ClutStart, texture.ClutMode);
            Texture previousTexture = cache.get(key);

            if (previousTexture != null)
            {
                previousTexture.deleteTexture(re);
//JAVA TO C# CONVERTER TODO TASK: There is no .NET LinkedList equivalent to the Java 'remove' method:
                vramTextures.remove(previousTexture);
            }
            else
            {
                // Check if the cache is not growing too large
                if (cache.size() >= cacheMaxSize)
                {
                    // Remove the LRU cache entry
                    IEnumerator <KeyValuePair <int, Texture> > it = cache.entrySet().GetEnumerator();
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                    if (it.hasNext())
                    {
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                        KeyValuePair <int, Texture> entry = it.next();
                        Texture lruTexture = entry.Value;
                        lruTexture.deleteTexture(re);
//JAVA TO C# CONVERTER TODO TASK: There is no .NET LinkedList equivalent to the Java 'remove' method:
                        vramTextures.remove(lruTexture);
//JAVA TO C# CONVERTER TODO TASK: .NET enumerators are read-only:
                        it.remove();

                        statistics.entriesRemoved++;
                    }
                }
            }

            cache.put(key, texture);
            if (isVramTexture(texture))
            {
                vramTextures.AddLast(texture);
            }

            if (cache.size() > statistics.maxSizeUsed)
            {
                statistics.maxSizeUsed = cache.size();
            }
        }
Esempio n. 4
0
        public virtual void addVertex(IRenderingEngine re, VertexInfo vertexInfo, int numberOfVertex, float[][] boneMatrix, int numberOfWeightsForShader)
        {
            lock (this)
            {
                int?       key            = getKey(vertexInfo);
                VertexInfo previousVertex = cache.get(key);
                if (previousVertex != null)
                {
                    vertexInfo.reuseCachedBuffer(previousVertex);
                    previousVertex.deleteVertex(re);
                }
                else
                {
                    // Check if the cache is not growing too large
                    if (cache.size() >= cacheMaxSize)
                    {
                        // Remove the LRU cache entry
                        IEnumerator <KeyValuePair <int, VertexInfo> > it = cache.entrySet().GetEnumerator();
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                        if (it.hasNext())
                        {
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                            KeyValuePair <int, VertexInfo> entry = it.next();
                            entry.Value.deleteVertex(re);
//JAVA TO C# CONVERTER TODO TASK: .NET enumerators are read-only:
                            it.remove();

                            statistics.entriesRemoved++;
                        }
                    }
                }

                vertexInfo.prepareForCache(this, numberOfVertex, boneMatrix, numberOfWeightsForShader);
                cache.put(key, vertexInfo);

                if (cache.size() > statistics.maxSizeUsed)
                {
                    statistics.maxSizeUsed = cache.size();
                }
            }
        }
Esempio n. 5
0
        private static ICollection <Path> HitsToPaths(ICollection <Hit> depthHits, Node start, Node end, bool stopAsap, int maxResultCount)
        {
            LinkedHashMap <string, Path> paths = new LinkedHashMap <string, Path>();

            foreach (Hit hit in depthHits)
            {
                foreach (Path path in HitToPaths(hit, start, end, stopAsap))
                {
                    paths.put(path.ToString(), path);
                    if (paths.size() >= maxResultCount)
                    {
                        break;
                    }
                }
            }
            return(paths.values());
        }
Esempio n. 6
0
 internal virtual TypeParameter[] TypeParameters()
 {
     if (TypeParametersConflict == null)
     {
         return(TypeParameter.NoParameters);
     }
     else
     {
         TypeParameter[] result = new TypeParameter[TypeParametersConflict.size()];
         int             i      = 0;
         foreach (KeyValuePair <string, TypeReference.Bound> entry in TypeParametersConflict.entrySet())
         {
             result[i++] = new TypeParameter(entry.Key, entry.Value);
         }
         return(result);
     }
 }
Esempio n. 7
0
 /*
  * Returns the number of {@code ZipEntries} in this {@code ZipFile}.
  *
  * @return the number of entries in this file.
  * @throws IllegalStateException if this ZIP file has been closed.
  */
 public int size()
 {
     checkNotClosed();
     return(mEntries.size());
 }
Esempio n. 8
0
 public virtual int size()
 {
     return(subModelMap.size());
 }
Esempio n. 9
0
 internal FxMatrixBuilder(ImmutableMap <Currency, int> currencies, double[][] rates)
 {
     this.currencies = new LinkedHashMap <Currency, int>(currencies);
     // Ensure there is space to add at least one new currency
     this.rates = copyArray(rates, size(currencies.size() + 1));
 }