<bdo id='rRFVs'></bdo><ul id='rRFVs'></ul>
<tfoot id='rRFVs'></tfoot>

  1. <legend id='rRFVs'><style id='rRFVs'><dir id='rRFVs'><q id='rRFVs'></q></dir></style></legend>
    1. <i id='rRFVs'><tr id='rRFVs'><dt id='rRFVs'><q id='rRFVs'><span id='rRFVs'><b id='rRFVs'><form id='rRFVs'><ins id='rRFVs'></ins><ul id='rRFVs'></ul><sub id='rRFVs'></sub></form><legend id='rRFVs'></legend><bdo id='rRFVs'><pre id='rRFVs'><center id='rRFVs'></center></pre></bdo></b><th id='rRFVs'></th></span></q></dt></tr></i><div id='rRFVs'><tfoot id='rRFVs'></tfoot><dl id='rRFVs'><fieldset id='rRFVs'></fieldset></dl></div>

    2. <small id='rRFVs'></small><noframes id='rRFVs'>

      获取 Set<T> 中索引处的对象

      时间:2023-07-08
      <i id='jJEF4'><tr id='jJEF4'><dt id='jJEF4'><q id='jJEF4'><span id='jJEF4'><b id='jJEF4'><form id='jJEF4'><ins id='jJEF4'></ins><ul id='jJEF4'></ul><sub id='jJEF4'></sub></form><legend id='jJEF4'></legend><bdo id='jJEF4'><pre id='jJEF4'><center id='jJEF4'></center></pre></bdo></b><th id='jJEF4'></th></span></q></dt></tr></i><div id='jJEF4'><tfoot id='jJEF4'></tfoot><dl id='jJEF4'><fieldset id='jJEF4'></fieldset></dl></div>
    3. <tfoot id='jJEF4'></tfoot>

        • <legend id='jJEF4'><style id='jJEF4'><dir id='jJEF4'><q id='jJEF4'></q></dir></style></legend>

              <tbody id='jJEF4'></tbody>

                <bdo id='jJEF4'></bdo><ul id='jJEF4'></ul>

                <small id='jJEF4'></small><noframes id='jJEF4'>

              • 本文介绍了获取 Set<T> 中索引处的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                在 Swift 1.2 中有一个 Set 对象,您可以使用它来创建静态类型的 Set.

                In Swift 1.2 there is a Set object, which you can use to create a static typed Set.

                我不知道如何在某个索引处获取对象.它有一个 subscript 允许您执行以下操作:mySet[setIndex].

                I cannot find out how to get the object at a certain index. It has a subscript that allows you to do the following: mySet[setIndex].

                这将检索该 setIndex 处的对象.但是现在我想从某个 Int 索引中获取一个对象.

                This retrieves the object at that setIndex. But now I want to get an object from a certain Int index.

                var myObject = mySet[sIndex];
                

                但是如何创建具有特定索引"的 SetIndex?

                But how do I create a SetIndex with a certain 'index'?

                推荐答案

                Swift 3 及更新版本

                您可以offsetBy:来自 .startIndex:

                let mySet: Set = ["a", "b", "c", "d"]
                mySet[mySet.index(mySet.startIndex, offsetBy: 2)] // -> something from the set.
                

                Swift 2(过时)

                你可以advancedBy() from .startIndex:

                let mySet: Set = ["a", "b", "c", "d"]
                mySet[mySet.startIndex.advancedBy(2)] // -> something from the set.
                

                Swift 1.x(过时)

                类似于String,你必须从.startIndex advance():

                let mySet: Set = ["a", "b", "c", "d"]
                mySet[advance(mySet.startIndex, 2)] // -> something from the set.
                

                这篇关于获取 Set<T> 中索引处的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:如何在微调器中设置位置? 下一篇:android - 从网络服务器保存图像并将其设置为壁纸

                相关文章

                <i id='qYNfb'><tr id='qYNfb'><dt id='qYNfb'><q id='qYNfb'><span id='qYNfb'><b id='qYNfb'><form id='qYNfb'><ins id='qYNfb'></ins><ul id='qYNfb'></ul><sub id='qYNfb'></sub></form><legend id='qYNfb'></legend><bdo id='qYNfb'><pre id='qYNfb'><center id='qYNfb'></center></pre></bdo></b><th id='qYNfb'></th></span></q></dt></tr></i><div id='qYNfb'><tfoot id='qYNfb'></tfoot><dl id='qYNfb'><fieldset id='qYNfb'></fieldset></dl></div>
                  <bdo id='qYNfb'></bdo><ul id='qYNfb'></ul>
                <tfoot id='qYNfb'></tfoot>

                <small id='qYNfb'></small><noframes id='qYNfb'>

              • <legend id='qYNfb'><style id='qYNfb'><dir id='qYNfb'><q id='qYNfb'></q></dir></style></legend>