// Path: android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/model/PagePart.java
// public class PagePart {
// 
//     private int page;
// 
//     private Bitmap renderedBitmap;
// 
//     private RectF pageRelativeBounds;
// 
//     private boolean thumbnail;
// 
//     private int cacheOrder;
// 
//     public PagePart(int page, Bitmap renderedBitmap, RectF pageRelativeBounds, boolean thumbnail, int cacheOrder) {
//         super();
//         this.page = page;
//         this.renderedBitmap = renderedBitmap;
//         this.pageRelativeBounds = pageRelativeBounds;
//         this.thumbnail = thumbnail;
//         this.cacheOrder = cacheOrder;
//     }
// 
//     public int getCacheOrder() {
//         return cacheOrder;
//     }
// 
//     public int getPage() {
//         return page;
//     }
// 
//     public Bitmap getRenderedBitmap() {
//         return renderedBitmap;
//     }
// 
//     public RectF getPageRelativeBounds() {
//         return pageRelativeBounds;
//     }
// 
//     public boolean isThumbnail() {
//         return thumbnail;
//     }
// 
//     public void setCacheOrder(int cacheOrder) {
//         this.cacheOrder = cacheOrder;
//     }
// 
//     @Override
//     public boolean equals(Object obj) {
//         if (!(obj instanceof PagePart)) {
//             return false;
//         }
// 
//         PagePart part = (PagePart) obj;
//         return part.getPage() == page
//                 && part.getPageRelativeBounds().left == pageRelativeBounds.left
//                 && part.getPageRelativeBounds().right == pageRelativeBounds.right
//                 && part.getPageRelativeBounds().top == pageRelativeBounds.top
//                 && part.getPageRelativeBounds().bottom == pageRelativeBounds.bottom;
//     }
// 
// }
// 
// Path: android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/util/Constants.java
// public static int CACHE_SIZE = 120;
// 
// Path: android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/util/Constants.java
// public static int THUMBNAILS_CACHE_SIZE = 8;


import android.graphics.RectF;
import android.support.annotation.Nullable;
import com.github.barteksc.pdfviewer.model.PagePart;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.PriorityQueue;
import static com.github.barteksc.pdfviewer.util.Constants.Cache.CACHE_SIZE;
import static com.github.barteksc.pdfviewer.util.Constants.Cache.THUMBNAILS_CACHE_SIZE;

/**
 * Copyright 2016 Bartosz Schiller
 * <p/>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p/>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p/>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.github.barteksc.pdfviewer;





class CacheManager {

    private final PriorityQueue<PagePart> passiveCache;

    private final PriorityQueue<PagePart> activeCache;

    private final List<PagePart> thumbnails;

    private final Object passiveActiveLock = new Object();

    private final PagePartComparator orderComparator = new PagePartComparator();

    public CacheManager() {

// Path: android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/model/PagePart.java
// public class PagePart {
// 
//     private int page;
// 
//     private Bitmap renderedBitmap;
// 
//     private RectF pageRelativeBounds;
// 
//     private boolean thumbnail;
// 
//     private int cacheOrder;
// 
//     public PagePart(int page, Bitmap renderedBitmap, RectF pageRelativeBounds, boolean thumbnail, int cacheOrder) {
//         super();
//         this.page = page;
//         this.renderedBitmap = renderedBitmap;
//         this.pageRelativeBounds = pageRelativeBounds;
//         this.thumbnail = thumbnail;
//         this.cacheOrder = cacheOrder;
//     }
// 
//     public int getCacheOrder() {
//         return cacheOrder;
//     }
// 
//     public int getPage() {
//         return page;
//     }
// 
//     public Bitmap getRenderedBitmap() {
//         return renderedBitmap;
//     }
// 
//     public RectF getPageRelativeBounds() {
//         return pageRelativeBounds;
//     }
// 
//     public boolean isThumbnail() {
//         return thumbnail;
//     }
// 
//     public void setCacheOrder(int cacheOrder) {
//         this.cacheOrder = cacheOrder;
//     }
// 
//     @Override
//     public boolean equals(Object obj) {
//         if (!(obj instanceof PagePart)) {
//             return false;
//         }
// 
//         PagePart part = (PagePart) obj;
//         return part.getPage() == page
//                 && part.getPageRelativeBounds().left == pageRelativeBounds.left
//                 && part.getPageRelativeBounds().right == pageRelativeBounds.right
//                 && part.getPageRelativeBounds().top == pageRelativeBounds.top
//                 && part.getPageRelativeBounds().bottom == pageRelativeBounds.bottom;
//     }
// 
// }
// 
// Path: android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/util/Constants.java
// public static int CACHE_SIZE = 120;
// 
// Path: android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/util/Constants.java
// public static int THUMBNAILS_CACHE_SIZE = 8;


// Path: android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/CacheManager.java
import android.graphics.RectF;
import android.support.annotation.Nullable;
import com.github.barteksc.pdfviewer.model.PagePart;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.PriorityQueue;
import static com.github.barteksc.pdfviewer.util.Constants.Cache.CACHE_SIZE;
import static com.github.barteksc.pdfviewer.util.Constants.Cache.THUMBNAILS_CACHE_SIZE;

/**
 * Copyright 2016 Bartosz Schiller
 * <p/>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p/>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p/>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.github.barteksc.pdfviewer;





class CacheManager {

    private final PriorityQueue<PagePart> passiveCache;

    private final PriorityQueue<PagePart> activeCache;

    private final List<PagePart> thumbnails;

    private final Object passiveActiveLock = new Object();

    private final PagePartComparator orderComparator = new PagePartComparator();

    public CacheManager() {

        activeCache = new PriorityQueue<>(CACHE_SIZE, orderComparator);
