Last active
August 24, 2017 14:08
-
-
Save dudarenko-io/eda8b060355f410122aa0bb75b326242 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Dictionary where Value: Collection { | |
/// A Boolean value indicating whether all collection-values in dictionary is empty. | |
var isContentsEmpty: Bool { | |
for collection in values where !collection.isEmpty { | |
return false | |
} | |
return true | |
} | |
} | |
extension Dictionary where Value: Collection, Value.IndexDistance == Int { | |
/// The number of elements in all dictionary`s values-collections. | |
var totalCount: Int { | |
return self.reduce(0) { (count, keyValue) -> Int in | |
count + keyValue.value.count | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment