Android Open Source - FoodFinderApp Keep






From Project

Back to project page FoodFinderApp.

License

The source code is released under:

GNU General Public License

If you think the Android project FoodFinderApp listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.json.zip;
/*from w w  w  .ja  v  a2 s. co  m*/

/*
 Copyright (c) 2013 JSON.org

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:

 The above copyright notice and this permission notice shall be included in all
 copies or substantial portions of the Software.

 The Software shall be used for Good, not Evil.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 SOFTWARE.
 */

/**
 * A keep is a data structure that associates strings (or substrings) with
 * numbers. This allows the sending of small integers instead of strings.
 *
 * @author JSON.org
 * @version 2013-04-18
 */
abstract class Keep implements None, PostMortem {
    protected int capacity;
    protected int length;
    protected int power;
    protected long[] uses;

    public Keep(int bits) {
        this.capacity = JSONzip.twos[bits];
        this.length = 0;
        this.power = 0;
        this.uses = new long[this.capacity];
    }

    /**
     * When an item ages, its use count is reduced by at least half.
     *
     * @param use
     *            The current use count of an item.
     * @return The new use count for that item.
     */
    public static long age(long use) {
        return use >= 32 ? 16 : use / 2;
    }

    /**
     * Return the number of bits required to contain an integer based on the
     * current length of the keep. As the keep fills up, the number of bits
     * required to identify one of its items goes up.
     */
    public int bitsize() {
        while (JSONzip.twos[this.power] < this.length) {
            this.power += 1;
        }
        return this.power;
    }

    /**
     * Increase the usage count on an integer value.
     */
    public void tick(int integer) {
        this.uses[integer] += 1;
    }

    /**
     * Get the value associated with an integer.
     * @param integer The number of an item in the keep.
     * @return The value.
     */
    abstract public Object value(int integer);
}




Java Source Code List

cs499.examples.semesterproject.AddItemsActivity.java
cs499.examples.semesterproject.AndroidFoodBankOwnerServlet.java
cs499.examples.semesterproject.AsyncAddItems.java
cs499.examples.semesterproject.AsyncAddPlace.java
cs499.examples.semesterproject.AsyncAddRestaurantToDB.java
cs499.examples.semesterproject.AsyncAuthenticateUser.java
cs499.examples.semesterproject.AsyncSearchAndShowPlaces.java
cs499.examples.semesterproject.AsyncSearchItems.java
cs499.examples.semesterproject.AsyncSendRequest.java
cs499.examples.semesterproject.AsyncViewRequests.java
cs499.examples.semesterproject.Constants.java
cs499.examples.semesterproject.DisplayMap.java
cs499.examples.semesterproject.DisplayMatchingPlaces.java
cs499.examples.semesterproject.DisplayPlaceItems.java
cs499.examples.semesterproject.DisplayPlace.java
cs499.examples.semesterproject.DisplayRequestActivity.java
cs499.examples.semesterproject.FoodBankOwnerActivity.java
cs499.examples.semesterproject.FoodOwnerOptions.java
cs499.examples.semesterproject.LoginActivity.java
cs499.examples.semesterproject.MainActivity.java
cs499.examples.semesterproject.OrganizationOptions.java
cs499.examples.semesterproject.OtherOwnerActivity.java
cs499.examples.semesterproject.QueryActivity.java
cs499.examples.semesterproject.ViewRequests.java
org.json.CDL.java
org.json.CookieList.java
org.json.Cookie.java
org.json.HTTPTokener.java
org.json.HTTP.java
org.json.JSONArray.java
org.json.JSONException.java
org.json.JSONML.java
org.json.JSONObject.java
org.json.JSONString.java
org.json.JSONStringer.java
org.json.JSONTokener.java
org.json.JSONWriter.java
org.json.Kim.java
org.json.Property.java
org.json.XMLTokener.java
org.json.XML.java
org.json.zip.BitInputStream.java
org.json.zip.BitOutputStream.java
org.json.zip.BitReader.java
org.json.zip.BitWriter.java
org.json.zip.Compressor.java
org.json.zip.Decompressor.java
org.json.zip.Huff.java
org.json.zip.JSONzip.java
org.json.zip.Keep.java
org.json.zip.MapKeep.java
org.json.zip.None.java
org.json.zip.PostMortem.java
org.json.zip.TrieKeep.java