Go to the source code of this file.
|
| static OOCacheImpl * | CacheAllocate (void) |
| |
| static void | CacheFree (OOCacheImpl *cache) |
| |
| static BOOL | CacheInsert (OOCacheImpl *cache, id key, id value) |
| |
| static BOOL | CacheRemove (OOCacheImpl *cache, id key) |
| |
| static BOOL | CacheRemoveOldest (OOCacheImpl *cache, NSString *logKey) |
| |
| static id | CacheRetrieve (OOCacheImpl *cache, id key) |
| |
| static unsigned | CacheGetCount (OOCacheImpl *cache) |
| |
| static NSArray * | CacheArrayOfContentsByAge (OOCacheImpl *cache) |
| |
| static NSArray * | CacheArrayOfNodesByAge (OOCacheImpl *cache) |
| |
| static NSString * | CacheGetName (OOCacheImpl *cache) |
| |
| static void | CacheSetName (OOCacheImpl *cache, NSString *name) |
| |
| static OOCacheNode * | CacheNodeAllocate (id< OOCacheComparable > key, id value) |
| |
| static void | CacheNodeFree (OOCacheImpl *cache, OOCacheNode *node) |
| |
| static id | CacheNodeGetValue (OOCacheNode *node) |
| |
| static void | CacheNodeSetValue (OOCacheNode *node, id value) |
| |
| static OOCacheNode * | TreeSplay (OOCacheNode **root, id< OOCacheComparable > key) |
| |
| static OOCacheNode * | TreeInsert (OOCacheImpl *cache, id< OOCacheComparable > key, id value) |
| |
| static void | AgeListMakeYoungest (OOCacheImpl *cache, OOCacheNode *node) |
| |
| static void | AgeListRemove (OOCacheImpl *cache, OOCacheNode *node) |
| |
◆ CHECK_INTEGRITY
| #define CHECK_INTEGRITY |
( |
|
context | ) |
do {} while (0) |
◆ OOCACHE_PERFORM_INTEGRITY_CHECKS
| #define OOCACHE_PERFORM_INTEGRITY_CHECKS 0 |
◆ OOCacheImpl
◆ OOCacheNode
◆ anonymous enum
◆ AgeListMakeYoungest()
◆ AgeListRemove()
◆ CacheAllocate()
◆ CacheArrayOfContentsByAge()
| static NSArray * CacheArrayOfContentsByAge |
( |
OOCacheImpl * |
cache | ) |
|
|
static |
◆ CacheArrayOfNodesByAge()
| static NSArray * CacheArrayOfNodesByAge |
( |
OOCacheImpl * |
cache | ) |
|
|
static |
Definition at line 550 of file OOCache.m.
551{
553 NSMutableArray *result =
nil;
554
555 if (cache == NULL || cache->
count == 0)
return nil;
556
557 result = [NSMutableArray arrayWithCapacity:cache->
count];
558
559 for (node = cache->
oldest; node != NULL; node = node->
younger)
560 {
562 }
563 return result;
564}
static NSString *const kSerializedEntryKeyKey
static NSString *const kSerializedEntryKeyValue
id< OOCacheComparable > key
References OOCacheImpl::count, nil, OOCacheImpl::oldest, and OOCacheNode::younger.
◆ CacheFree()
Definition at line 451 of file OOCache.m.
452{
453 if (cache == NULL) return;
454
456 [cache->
name autorelease];
457 free(cache);
458}
static void CacheNodeFree(OOCacheImpl *cache, OOCacheNode *node)
References CacheNodeFree(), and OOCacheImpl::root.
◆ CacheGetCount()
◆ CacheGetName()
◆ CacheInsert()
| static BOOL CacheInsert |
( |
OOCacheImpl * |
cache, |
|
|
id |
key, |
|
|
id |
value |
|
) |
| |
|
static |
Definition at line 461 of file OOCache.m.
462{
464
465 if (cache == NULL || key ==
nil || value ==
nil)
return NO;
466
468 if (node != NULL)
469 {
471 return YES;
472 }
473 else return NO;
474}
static void AgeListMakeYoungest(OOCacheImpl *cache, OOCacheNode *node)
static OOCacheNode * TreeInsert(OOCacheImpl *cache, id< OOCacheComparable > key, id value)
References AgeListMakeYoungest(), nil, and TreeInsert().
◆ CacheNodeAllocate()
◆ CacheNodeFree()
Definition at line 628 of file OOCache.m.
629{
630 id key, value;
631
632 if (node == NULL) return;
633
635
638 [key release];
639
642 [value release];
643
646
647 free(node);
648}
References AgeListRemove(), CacheNodeFree(), OOCacheNode::key, OOCacheNode::leftChild, nil, OOCacheNode::rightChild, and OOCacheNode::value.
Referenced by CacheFree(), CacheNodeFree(), CacheRemove(), and TreeInsert().
◆ CacheNodeGetValue()
◆ CacheNodeSetValue()
| static void CacheNodeSetValue |
( |
OOCacheNode * |
node, |
|
|
id |
value |
|
) |
| |
|
static |
◆ CacheRemove()
| static BOOL CacheRemove |
( |
OOCacheImpl * |
cache, |
|
|
id |
key |
|
) |
| |
|
static |
◆ CacheRemoveOldest()
| static BOOL CacheRemoveOldest |
( |
OOCacheImpl * |
cache, |
|
|
NSString * |
logKey |
|
) |
| |
|
static |
◆ CacheRetrieve()
| static id CacheRetrieve |
( |
OOCacheImpl * |
cache, |
|
|
id |
key |
|
) |
| |
|
static |
◆ CacheSetName()
| static void CacheSetName |
( |
OOCacheImpl * |
cache, |
|
|
NSString * |
name |
|
) |
| |
|
static |
◆ TreeInsert()
Definition at line 770 of file OOCache.m.
771{
773 *node = NULL;
774 NSComparisonResult order;
775
776 if (cache == NULL || key ==
nil || value ==
nil)
return NULL;
777
778 if (cache->
root == NULL)
779 {
783 }
784 else
785 {
787 if (node != NULL)
788 {
789
791 }
792 else
793 {
794 closest = cache->
root;
797
798 order = [key compare:closest->
key];
799
800 if (order == NSOrderedAscending)
801 {
802
808 }
809 else if (order == NSOrderedDescending)
810 {
811
817 }
818 else
819 {
820
821 OOLog(
@"dataCache.inconsistency",
@"%s() internal inconsistency for cache \"%@\
", insertion failed.", __PRETTY_FUNCTION__, cache->
name);
823 return NULL;
824 }
825 }
826 }
827
828 return node;
829}
static void CacheNodeSetValue(OOCacheNode *node, id value)
static OOCacheNode * CacheNodeAllocate(id< OOCacheComparable > key, id value)
References CacheNodeAllocate(), CacheNodeFree(), CacheNodeSetValue(), OOCacheImpl::count, EXPECT_NOT, OOCacheNode::leftChild, OOCacheImpl::name, nil, OOLog, OOCacheNode::rightChild, OOCacheImpl::root, and TreeSplay().
Referenced by CacheInsert().
◆ TreeSplay()
Definition at line 691 of file OOCache.m.
692{
693 NSComparisonResult order;
695 OOCacheNode *node = NULL, *temp = NULL, *l = &N, *r = &N;
696 BOOL exact = NO;
697
698 if (root == NULL || *root == NULL || key ==
nil)
return NULL;
699
700 node = *root;
701
702 for (;;)
703 {
704#ifndef NDEBUG
705 if (node == NULL)
706 {
707 OOLog(
@"node.error",
@"%@",
@"node is NULL");
708 }
709 else if (node->
key == NULL)
710 {
711 OOLog(
@"node.error",
@"%@",
@"node->key is NULL");
712 }
713#endif
714 order = [key compare:node->
key];
715 if (order == NSOrderedAscending)
716 {
717
719 if ([key compare:node->leftChild->key] == NSOrderedAscending)
720 {
721
725 node = temp;
727 }
728
730 r = node;
732 }
733 else if (order == NSOrderedDescending)
734 {
735
737 if ([key compare:node->rightChild->key] == NSOrderedDescending)
738 {
739
743 node = temp;
745 }
746
748 l = node;
750 }
751 else
752 {
753
754 exact = YES;
755 break;
756 }
757 }
758
759
764
765 *root = node;
766 return exact ? node : NULL;
767}
References OOCacheNode::key, OOCacheNode::leftChild, nil, OOLog, and OOCacheNode::rightChild.
Referenced by CacheRemove(), CacheRetrieve(), and TreeInsert().
◆ kSerializedEntryKeyKey
| NSString* const kSerializedEntryKeyKey = @"@"key" |
|
static |
◆ kSerializedEntryKeyValue
| NSString* const kSerializedEntryKeyValue = @"@"value" |
|
static |