mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
# Conflicts: # Session.xcodeproj/project.pbxproj # Session/Meta/Session-Prefix.pch # Session/Notifications/SyncPushTokensJob.swift # Session/Utilities/BackgroundPoller.swift # SessionMessagingKit/Configuration.swift # SessionMessagingKit/Database/Models/Profile.swift # SessionMessagingKit/Jobs/Types/AttachmentDownloadJob.swift # SessionMessagingKit/Jobs/Types/AttachmentUploadJob.swift # SessionMessagingKit/Jobs/Types/DisappearingMessagesJob.swift # SessionMessagingKit/Jobs/Types/FailedAttachmentDownloadsJob.swift # SessionMessagingKit/Jobs/Types/FailedMessageSendsJob.swift # SessionMessagingKit/Jobs/Types/GroupLeavingJob.swift # SessionMessagingKit/Jobs/Types/MessageReceiveJob.swift # SessionMessagingKit/Jobs/Types/MessageSendJob.swift # SessionMessagingKit/Jobs/Types/NotifyPushServerJob.swift # SessionMessagingKit/Jobs/Types/RetrieveDefaultOpenGroupRoomsJob.swift # SessionMessagingKit/Jobs/Types/SendReadReceiptsJob.swift # SessionMessagingKit/Jobs/Types/UpdateProfilePictureJob.swift # SessionMessagingKit/Sending & Receiving/MessageSender.swift # SessionMessagingKit/Sending & Receiving/Pollers/ClosedGroupPoller.swift # SessionMessagingKit/Utilities/AppReadiness.m # SessionMessagingKitTests/Open Groups/OpenGroupManagerSpec.swift # SessionMessagingKitTests/_TestUtilities/TestOnionRequestAPI.swift # SessionShareExtension/ShareNavController.swift # SessionSnodeKit/Jobs/GetSnodePoolJob.swift # SessionUtilitiesKit/Configuration.swift # SessionUtilitiesKit/Database/Utilities/Database+Utilities.swift # SessionUtilitiesKit/JobRunner/JobRunner.swift # SignalUtilitiesKit/Meta/SignalUtilitiesKit.h # SignalUtilitiesKit/Utilities/SSKAsserts.h
46 lines
1.2 KiB
Swift
46 lines
1.2 KiB
Swift
// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
|
|
|
|
import Foundation
|
|
|
|
public extension Set {
|
|
mutating func insert(contentsOf value: Set<Element>?) {
|
|
guard let value: Set<Element> = value else { return }
|
|
|
|
value.forEach { self.insert($0) }
|
|
}
|
|
|
|
func inserting(_ value: Element?) -> Set<Element> {
|
|
guard let value: Element = value else { return self }
|
|
|
|
var updatedSet: Set<Element> = self
|
|
updatedSet.insert(value)
|
|
|
|
return updatedSet
|
|
}
|
|
|
|
func inserting(contentsOf value: Set<Element>?) -> Set<Element> {
|
|
guard let value: Set<Element> = value else { return self }
|
|
|
|
var updatedSet: Set<Element> = self
|
|
value.forEach { updatedSet.insert($0) }
|
|
|
|
return updatedSet
|
|
}
|
|
|
|
func removing(_ value: Element?) -> Set<Element> {
|
|
guard let value: Element = value else { return self }
|
|
|
|
var updatedSet: Set<Element> = self
|
|
updatedSet.remove(value)
|
|
|
|
return updatedSet
|
|
}
|
|
|
|
mutating func popRandomElement() -> Element? {
|
|
guard let value: Element = randomElement() else { return nil }
|
|
|
|
self.remove(value)
|
|
return value
|
|
}
|
|
}
|