Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » LRUCache has the GetLRU () method, but does not have GetLRUKey()
LRUCache has the GetLRU () method, but does not have GetLRUKey() [message #50443] Wed, 31 October 2018 11:08 Go to next message
fermium is currently offline  fermium
Messages: 4
Registered: October 2018
Junior Member
In some situations, you need to know not only the value of the item to be removed from the cache, but also the key. The project I'm working on needs to get that key and do some work with it. I propose to add such functionality, like this:
template <class T, class K>
const K& LRUCacheKeyRet<T, K>::GetLRUKey()
{
	int tail = data[head].prev;
	return key[tail].key;
}
Re: LRUCache has the GetLRU () method, but does not have GetLRUKey() [message #50446 is a reply to message #50443] Wed, 31 October 2018 12:51 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 11700
Registered: November 2005
Ultimate Member
OK, why not, applied. Thanks and welcome to the forum.

Mirek
Re: LRUCache has the GetLRU () method, but does not have GetLRUKey() [message #50485 is a reply to message #50443] Thu, 08 November 2018 11:15 Go to previous messageGo to next message
fermium is currently offline  fermium
Messages: 4
Registered: October 2018
Junior Member
What about IsCached()?
template <class T, class K>
bool LRUCache<T, K>::IsCached(const Maker& m)
{
	Key k;
	k.key = m.Key();
	k.type = &typeid(m);
	int q = key.Find(k);
	if(q < 0)
		return false;
	else
		return true;
		
}
Re: LRUCache has the GetLRU () method, but does not have GetLRUKey() [message #50489 is a reply to message #50485] Sun, 11 November 2018 17:20 Go to previous message
mirek is currently offline  mirek
Messages: 11700
Registered: November 2005
Ultimate Member
fermium wrote on Thu, 08 November 2018 11:15
What about IsCached()?
template <class T, class K>
bool LRUCache<T, K>::IsCached(const Maker& m)
{
	Key k;
	k.key = m.Key();
	k.type = &typeid(m);
	int q = key.Find(k);
	if(q < 0)
		return false;
	else
		return true;
		
}


Not fundamentally oposed, but I would really like to know what is the real life usage?
Previous Topic: XmlParser::IsEnd() should be declared as const
Next Topic: Error in DUMP_ declaration
Goto Forum:
  


Current Time: Sun Feb 17 11:21:05 CET 2019

Total time taken to generate the page: 0.00849 seconds