Skip to content

Commit

Permalink
Add count tracking to NanoTDFManager
Browse files Browse the repository at this point in the history
A count property has been introduced to the NanoTDFManager to keep track of the number of NanoTDFs. Functions have been adjusted to increment/decrement the count when NanoTDFs are added/removed. Additionally, a new getCount function has been introduced to retrieve the count.
  • Loading branch information
arkavo-com committed Jul 3, 2024
1 parent f439039 commit 3d43903
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion OpenTDFKit/NanoTDFManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import Foundation

class NanoTDFManager {
private var nanoTDFs: [Data: NanoTDF] = [:]
private var count: Int = 0

func addNanoTDF(_ nanoTDF: NanoTDF, withIdentifier identifier: Data) {
nanoTDFs[identifier] = nanoTDF
count += 1
}

func getNanoTDF(withIdentifier identifier: Data) -> NanoTDF? {
Expand All @@ -16,6 +18,16 @@ class NanoTDFManager {
}

func removeNanoTDF(withIdentifier identifier: Data) {
nanoTDFs.removeValue(forKey: identifier)
if nanoTDFs.removeValue(forKey: identifier) != nil {
count -= 1
}
}

func isEmpty() -> Bool {
return nanoTDFs.isEmpty
}

func getCount() -> Int {
return count
}
}

0 comments on commit 3d43903

Please sign in to comment.