Package net.sf.cache4j.impl

Source Code of net.sf.cache4j.impl.LFUComparator

/* =========================================================================
* File: $Id: $LFUComparator.java,v$
*
* Copyright (c) 2006, Yuriy Stepovoy. All rights reserved.
* email: stepovoy@gmail.com
*
* =========================================================================
*/

package net.sf.cache4j.impl;

import net.sf.cache4j.impl.CacheObject;

import java.util.Comparator;

/**
* ����� LFUComparator ������������ ��� ��������� �������� � ������������ �
* ���������� LFU (Least Frequently Used).
* ���� ��� ��������� ������ ������� ��� �������������, �� ������� ��� ����������
* ��������, �� ��������� ������ ������� ������������� ���������� ���������� ���.
*
* @version $Revision: 1.0 $ $Date:$
* @author Yuriy Stepovoy. <a href="mailto:stepovoy@gmail.com">stepovoy@gmail.com</a>
**/

public class LFUComparator implements Comparator {
// ----------------------------------------------------------------------------- ���������
// ----------------------------------------------------------------------------- �������� ������
// ----------------------------------------------------------------------------- ����������� ����������
// ----------------------------------------------------------------------------- ������������
// ----------------------------------------------------------------------------- Public ������

    public int compare(Object o1, Object o2) {
        CacheObject co1 = (CacheObject)o1;
        CacheObject co2 = (CacheObject)o2;
        return co1.getAccessCount()<co2.getAccessCount() ?
                  -1
                : co1.getAccessCount()==co2.getAccessCount() ?
                    ( co1.getId()<co2.getId() ? -1 : (co1.getId()==co2.getId() ? 0 : 1) )
                     : 1;
    }


    public boolean equals(Object obj) {
        return obj==null ? false : (obj instanceof LFUComparator);
    }

// ----------------------------------------------------------------------------- Package scope ������
// ----------------------------------------------------------------------------- Protected ������
// ----------------------------------------------------------------------------- Private ������
// ----------------------------------------------------------------------------- Inner ������
}

/*
$Log: LFUComparator.java,v $
*/
 
TOP

Related Classes of net.sf.cache4j.impl.LFUComparator

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.