Giter VIP home page Giter VIP logo

ordereddictionary's People

Contributors

callo90 avatar galcohen avatar gl2748 avatar graphiclife avatar lukaskubanek avatar maicki avatar mbrgm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ordereddictionary's Issues

Precondition Failed: Inconsistency error occurred in OrderedDictionary

Thanks for creating and maintaining this library, it's been very useful to me.

I recently encountered the below crashing error in OrderedDictionary while running my server:

Precondition failed: Inconsistency error occurred in OrderedDictionary: file /home/xander/dev/my_project/.build/checkouts/OrderedDictionary/Sources/OrderedDictionary.swift, line 291

which corresponds to this line. It appears that it's attempting to return nil for an existing key.

My full backtrace:

(lldb) thread backtrace
* thread #1, name = 'MyApp', stop reason = Precondition failed: Inconsistency error occurred in OrderedDictionary
  * frame #0: 0x00007ffff7c37110 libswiftCore.so`_swift_runtime_on_report
    frame #1: 0x00007ffff7cacb85 libswiftCore.so`_swift_stdlib_reportFatalErrorInFile + 213
    frame #2: 0x00007ffff79484a2 libswiftCore.so`closure #1 (Swift.UnsafeBufferPointer<Swift.UInt8>) -> () in closure #1 (Swift.UnsafeBufferPointer<Swift.UInt8>) -> () in closure #1 (Swift.UnsafeBufferPointer<Swift.UInt8>) -> () in Swift._assertionFailure(_: Swift.StaticString, _: Swift.String, file: Swift.StaticString, line: Swift.UInt, flags: Swift.UInt32) -> Swift.Never + 242
    frame #3: 0x00007ffff79480e6 libswiftCore.so`closure #1 (Swift.UnsafeBufferPointer<Swift.UInt8>) -> () in closure #1 (Swift.UnsafeBufferPointer<Swift.UInt8>) -> () in Swift._assertionFailure(_: Swift.StaticString, _: Swift.String, file: Swift.StaticString, line: Swift.UInt, flags: Swift.UInt32) -> Swift.Never + 86
    frame #4: 0x00007ffff7948685 libswiftCore.so`function signature specialization <Arg[1] = [Closure Propagated : closure #1 (Swift.UnsafeBufferPointer<Swift.UInt8>) -> () in closure #1 (Swift.UnsafeBufferPointer<Swift.UInt8>) -> () in Swift._assertionFailure(_: Swift.StaticString, _: Swift.String, file: Swift.StaticString, line: Swift.UInt, flags: Swift.UInt32) -> Swift.Never, Argument Types : [Swift.StaticStringSwift.UnsafeBufferPointer<Swift.UInt8>Swift.UIntSwift.UInt32]> of generic specialization <()> of Swift.String.withUTF8<τ_0_0>((Swift.UnsafeBufferPointer<Swift.UInt8>) throws -> τ_0_0) throws -> τ_0_0 + 181
    frame #5: 0x00007ffff7946d10 libswiftCore.so`Swift._assertionFailure(_: Swift.StaticString, _: Swift.String, file: Swift.StaticString, line: Swift.UInt, flags: Swift.UInt32) -> Swift.Never + 528
    frame #6: 0x0000555555e95e9b MyApp`OrderedDictionary._unsafeValue(key=MyLib.MyData @ 0x00007fffffffc4b0, self=OrderedDictionary.OrderedDictionary<MyLib.MyData, MyLib.MyDataStream> @ 0x00007fffffffc460) at OrderedDictionary.swift:291:9
    frame #7: 0x0000555555e962e1 MyApp`OrderedDictionary.subscript.getter(position=219, self=OrderedDictionary.OrderedDictionary<MyLib.MyData, MyLib.MyDataStream> @ 0x00007fffffffc6a0) at OrderedDictionary.swift:313:21
    frame #8: 0x0000555555e9be5b MyApp`OrderedDictionary.subscript.read(position=219, self=OrderedDictionary.OrderedDictionary<MyLib.MyData, MyLib.MyDataStream> @ 0x00007fffffffc770) at OrderedDictionary.swift:0
    frame #9: 0x0000555555e9bb75 MyApp`protocol witness for Collection.subscript.read in conformance OrderedDictionary<A, B> at <compiler-generated>:0
    frame #10: 0x00007ffff797597f libswiftCore.so`protocol witness for Swift.IteratorProtocol.next() -> Swift.Optional<τ_0_0.Element> in conformance Swift.IndexingIterator<τ_0_0> : Swift.IteratorProtocol in Swift + 463
    frame #11: 0x00007ffff7a347a5 libswiftCore.so`Swift.LazyMapSequence.Iterator.next() -> Swift.Optional<τ_0_1> + 197
    frame #12: 0x0000555556043caf MyApp`MyDataHandler.stopAndFlushData(self=0x000055555751f3a0) at MyDataHandler.swift:360:9
    frame #13: 0x00005555560b7c07 MyApp`normalRun() at TimeSeriesRun.swift:96:34
    frame #14: 0x00005555560b89c9 MyApp`runOnlineLearner() at TimeSeriesRun.swift:130:5
    frame #15: 0x0000555555fee8ef MyApp`main() at main.swift:12:5
    frame #16: 0x0000555555fee834 MyApp`main at main.swift:15:1
    frame #17: 0x00007fffabb09b97 libc.so.6`__libc_start_main + 231
    frame #18: 0x00005555557f83aa MyApp`_start + 42

MyDataHandler.swift:360 is this code in my project:

        for myDataStream in self.dataStreams.orderedValues { // This is line 360
            stopStreamsFutures.append(myDataStream.close())
        }

self.dataStreams is:

    var dataStreams: OrderedDictionary<MyData, MyDataStream> = []

and MyData is a struct:

struct MyData: Decodable & CustomStringConvertible & Hashable & Encodable & Equatable {
    let name: String
...

    static func == (lhs: MyData, rhs: MyData) -> Bool {
        return lhs.name == rhs.name
    }
...
}

I don't see this error on every server run. The only unusual aspect of this server run is that it hit a rare case where MyData keys had to be removed from the OrderedDictionary. There is a situation where I will set values to nil for existing keys when those MyData objects are no longer needed: self.dataStreams[myData] = nil, but this is indicated as the correct way to remove key-value pairs in the example code. One possibility is that the keys that were set to nil were later added back with a new value, but I don't think that should matter.

My server is heavily multi-threaded, but I don't currently see any potential concurrency issues here. This particular call in my code is at the end of the server's life when a stop command has been issued to flush and close all data streams. The call is made on the main thread. Running with the thread sanitizer doesn't show any issues.

Do you have any thoughts on what might be going wrong here?

`filter` should return a new OrderedDictionary, not an array of Key-Value pairs

When calling filter on an unordered Dictionary, you receive a new Dictionary, but oddly, when calling filter on an OrderedDictionary, you receive an array of tuples. I think it would be better to receive a new OrderedDictionary instead. It would also be good to have a new filtered method as well that filters in place.

V3.0.0 CFBundleShortVersionString missing

I've updated the framework to v.3.0.0 with Carthage, and I'm getting an error while submitting to the appStore:
parameter ErrorMessage = ERROR ITMS-90057: "The bundle 'Payload/PolitieApp.app/Frameworks/OrderedDictionary.framework' is missing plist key. The Info.plist file is missing the required key: CFBundleShortVersionString. Please find more information about CFBundleShortVersionString at https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleshortversionstring

Need sample code

Hi,

Could you please provide sample code and documentation??

I have a unsorted dictionary. how can I use your library to make it as orderdDict

It's bit tricky with init methods(Elements/Sequences). Please suggest as I am new to Swift.

Thanks in advance.

Package.swift seems invalid for Swift 4.2.1

After this commit, I cannot build the repository with swift build and Swift 4.2.1.

The issue seems to be a breaking change between the PackageDescription APIs 4 and 4.2.

I'm not sure if changing the first line to say // swift-tools-version: 4 would help, maybe then the old format would be selected.

How to set value?

I want to fill up value from json data but it didn't work

// json data
let abc:[String:AnyObject] = ["A": [1], "B": [2], "C": [3], "D": [4]]
var od: OrderedDictionary<String, AnyObject> = abc

error: cannot convert value of type '[String : AnyObject]' to specified type 'OrderedDictionary<String, AnyObject>'
var od: OrderedDictionary<String, AnyObject> = abc

I've tried

var od: OrderedDictionary<String, AnyObject> = abc as! OrderedDictionary<String, AnyObject>

But didn't work also

Key based access fails with error when Dictionary key is an integer type

Consider the following:

let dict: OrderedDictionary<UInt, String> = [1: "1", 2: "2", 3: "3"]
let x = dict[4]

The compiler will not complain and this will throw an error by the precondition in the index based subscript.

The expected behavior is like base Dictionary, returning nil when the key doesn't exists.

This happens because in this case, the requested key (4) is assumed to be an Int and therefore the index subscript gets called instead of the key subscript.

In the following case:

let dict: OrderedDictionary<Int, String> = [1: "1", 2: "2", 3: "3"]
let x = dict[4]

The compiler will complain about ambiguous use of 'subscript' . It can be resolved by explicitly casting the result to value's type but makes the OrderedDictionary less usable.

I think the solution here is to wrap the index with a specific index type to resolve any possible ambiguity between the index and key. Which is what the foundation's Dictionary does.

how to convert [String:[[String:AnyObject]]] to OrderedDictionary type?

how to convert [String:[[String:AnyObject]]] to OrderedDictionary type?

let orderedDictionary: OrderedDictionary<String, Any> = (self.dic as? OrderedDictionary)!

warning message
Cast from '[String : [[String : Any]]]' to unrelated type 'OrderedDictionary<String, Any>' always fails

The Server SSL certificate failed to verify

Using Xcode 14.1 with a project set to target macOS 13.0, Xcode was unable to update Swift Package OrderedDictionary, displaying the error message "The Server SSL certificate failed to verify". This was not a problem when targeting macOS 10.15. It may also be a problem when targeting macOS 12.

Ultimately, Xcode seems to continue attempting to build the whole project without ever succeeding.

Safe for app extensions

When linking the framework for an extension there's a warning saying the framework is not safe for use in app extensions. Fixable?

Swift package manager

Would be great if OrderedDictionary was compatible with SPM

Big thanks for this lib btw, I've used it in several projects

Keys of type Int

It looks like declaring the key as Int breaks accessing elements by index. Try this in a playground:

var dict = OrderedDictionary<Int, Int>
dict[0] = 1
dict[5] = 20
dict[0]
dict[5]

You'll get a compile error on the last two lines saying Ambiguous use of 'subscript'.

This makes complete sense, but it makes using the subscripts useless if the key type is Int. Any ideas?

Thanks,
David

SwiftUI ForEach?

I'm curious to learn whether this OrderedDictionary can work with SwiftUI ForEach.

A swift3 branch is welcome

public func index(after i: OrderedDictionary.Index) -> OrderedDictionary.Index {
    return (i + 1)
  }

This is all was needed to make it compile (to satisfy protocol changes). Still there are some warnings.

OrderedDictionary does not serialize to JSON using JSONSerialization or JSONEncoder

This is not a bug but moreover, a feature request.

what I would like to see is the dictionary getting converted to JSON using the native JSONSerialization class or JSONEncoder if you can add support for that it will be really awesome.

I tried to use the OrderedDictionary and tried to convert it to JSON using the below code

let serializedData = try! JSONSerialization.data(withJSONObject: orderedDictionaryObj, options: [])
    let encodedData = String(data: serializedData, encoding: String.Encoding.utf8)

but for now if you try to do something like this the JSONSerialization throws an exception. It will be really nice if you can add an extension method or expose a property to do this like

orderedDictionaryObject.ToJSONString()

Really appreciate the work and thanks for sharing this

Cocoapods support

Great lib. Any specific reason why its not on cocoapods? If you just didn't had time to do it I can prepare podfile to help.

Task failed with exit code 65 in Swift4 Xcode 9

hi, I want to use xcode9 (Swift 4) for new project, but I can't use carthage to build a framework

this the build failed message:
The “Swift Language Version” (SWIFT_VERSION) build setting must be set to a supported value for targets which use Swift. This setting can be set in the build settings editor.

Archive issue

Hey guys,

Im getting this error after archiving and submitted a new version using xcode 9
screen shot 2017-09-20 at 1 09 54 am

Framework plist
screen shot 2017-09-20 at 1 11 38 am

You might need your current version format and use only numbers instead

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.