<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Hbucius,<div class=""><br class=""></div><div class="">You can define your own `Array2D` type that uses a 1-dimensional array as backing (for fast performance) but exposes a high-level 2-dimensional array API.</div><div class=""><br class=""></div><div class="">Here’s a really primitive starting point I found on GitHub:</div><div class=""><a href="https://github.com/raywenderlich/swift-algorithm-club/blob/master/Array2D/Array2D.swift" class="">https://github.com/raywenderlich/swift-algorithm-club/blob/master/Array2D/Array2D.swift</a></div><div class=""><br class=""></div><div class="">Cheers,</div><div class="">Jaden Geller</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Apr 18, 2017, at 11:39 PM, Saagar Jha via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">It might be helpful if you showed a bit more of the code you’re working on, so that we can better see what you’re trying to do. Is there any operation in particular that is slow?<div class=""><br class=""></div><div class="">Also, CC’ing swift-users since I think it belongs there.</div><div class=""><br class=""><div class="">
<div style="letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Saagar Jha</div>
</div>
<br class=""><div class=""><blockquote type="cite" class=""><div class="">On Apr 18, 2017, at 22:57, Hbucius Smith via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_default" style="font-family:simsun,serif;font-size:small">Hello Swift community,</div><div class="gmail_default" style="font-family:simsun,serif;font-size:small"><br class=""></div><div class="gmail_default" style="font-family:simsun,serif;font-size:small"><br class=""></div><div class="gmail_default" style="font-family:simsun,serif;font-size:small"> When I used multidimensional array in swift, I found it is very low efficiency.</div><div class="gmail_default" style="font-family:simsun,serif;font-size:small"><br class=""></div><div class="gmail_default" style="font-family:simsun,serif;font-size:small"> </div><div class="gmail_default" style="font-family:simsun,serif;font-size:small"> I used in the following way : </div><div class="gmail_default" style="font-family:simsun,serif;font-size:small"><br class=""></div><div class="gmail_default" style="font-family:simsun,serif;font-size:small"> </div><div class="gmail_default" style="font-family:simsun,serif;font-size:small"><b class=""> var array = Array.init(repeating: Array.init(repeating: 0, count: 5), count: 5)</b></div><div class="gmail_default" style="font-family:simsun,serif;font-size:small"><b class=""> </b></div><div class="gmail_default" style="font-family:simsun,serif;font-size:small"><b class=""> array[0][0] = 0</b></div><div class="gmail_default" style="font-family:simsun,serif;font-size:small"><br class=""></div><div class="gmail_default" style="font-family:simsun,serif;font-size:small"> </div><div class="gmail_default" style="font-family:simsun,serif;font-size:small"> I have read some posts in stack overflow. It suggests using one dimension to fake multidimensional array. I think it is too ugly. DO we have better choice for this ?</div><div class="gmail_default" style="font-family:simsun,serif;font-size:small"><br class=""></div><div class="gmail_default" style="font-family:simsun,serif;font-size:small"> </div><div class="gmail_default" style="font-family:simsun,serif;font-size:small"> </div><div class="gmail_default" style="font-family:simsun,serif;font-size:small"><br class=""></div><div class="gmail_default" style="font-family:simsun,serif;font-size:small"><br class=""></div><br clear="all" class=""><div class=""><div class="gmail_signature" data-smartmail="gmail_signature"><i class=""><font face="georgia, serif" class="">best wishes for you </font></i></div></div>
</div>
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></div></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></div></body></html>