當前位置: 首頁>>代碼示例>>Python>>正文


Python Generic.List方法代碼示例

本文整理匯總了Python中System.Collections.Generic.List方法的典型用法代碼示例。如果您正苦於以下問題:Python Generic.List方法的具體用法?Python Generic.List怎麽用?Python Generic.List使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Collections.Generic的用法示例。


在下文中一共展示了Generic.List方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: DrawForeground

# 需要導入模塊: from System.Collections import Generic [as 別名]
# 或者: from System.Collections.Generic import List [as 別名]
def DrawForeground(self, e):

        lines = List[Line](self.lines_count)
        for i, j in self.lines:
            sp = self.points[i]
            ep = self.points[j]
            lines.Add(Line(Point3d(*sp), Point3d(*ep)))
        e.Display.DrawLines(lines, self.color, self.thickness)
        for i, (u, v) in enumerate(self.splines):
            sp = self.points[u]
            ep = self.points[v]
            th = self.spline_thickness[i]
            e.Display.DrawLine(Line(Point3d(*sp), Point3d(*ep)), self.spline_color, th)


# ==============================================================================
# Main
# ============================================================================== 
開發者ID:compas-dev,項目名稱:compas,代碼行數:20,代碼來源:__splines.py

示例2: test_generic_list

# 需要導入模塊: from System.Collections import Generic [as 別名]
# 或者: from System.Collections.Generic import List [as 別名]
def test_generic_list(self):
        """https://github.com/IronLanguages/ironpython2/issues/109"""
        from System.Collections.Generic import List
        lst = List[str]()
        lst.Add('Hello')
        lst.Add('World')
        vals = []
        for v in lst[1:]:
            vals.append(v)
        self.assertEqual(vals, ['World']) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:12,代碼來源:test_list.py

示例3: test_ipy2_gh39

# 需要導入模塊: from System.Collections import Generic [as 別名]
# 或者: from System.Collections.Generic import List [as 別名]
def test_ipy2_gh39(self):
        """https://github.com/IronLanguages/ironpython2/issues/39"""

        from System.Collections.Generic import List

        rng = range(10000)
        lst = List[object](rng)
        it = iter(lst)

        # Loop compilation occurs after 100 iterations, however it occurs in parallel.
        # Use a number >> 100 so that we actually hit the compiled code.
        for i in rng:
            self.assertEqual(i, next(it)) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:15,代碼來源:test_regressions.py

示例4: CompileAsDll

# 需要導入模塊: from System.Collections import Generic [as 別名]
# 或者: from System.Collections.Generic import List [as 別名]
def CompileAsDll(fileName, assemblyName):
    sources = List[str]()
    sources.Add(fileName)
    pc = PythonCompiler(sources, assemblyName)
    pc.TargetKind = System.Reflection.Emit.PEFileKinds.Dll
    pc.Compile() 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:8,代碼來源:test_ipyc.py

示例5: CompileOneFileAsConsoleApp1

# 需要導入模塊: from System.Collections import Generic [as 別名]
# 或者: from System.Collections.Generic import List [as 別名]
def CompileOneFileAsConsoleApp1(fileName, assemblyName, setMainFile) :
    sources = List[str]()
    sources.Add(fileName)
    pc = PythonCompiler(sources, assemblyName)
    if setMainFile:
        pc.MainFile = fileName
    pc.Compile() 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:9,代碼來源:test_ipyc.py

示例6: CompileOneFileAsConsoleApp2

# 需要導入模塊: from System.Collections import Generic [as 別名]
# 或者: from System.Collections.Generic import List [as 別名]
def CompileOneFileAsConsoleApp2(fileName, assemblyName):
    sources = List[str]()
    sources.Add(fileName)
    pc = PythonCompiler(sources, assemblyName)
    pc.MainFile = "NotExistFile"
    pc.Compile() 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:8,代碼來源:test_ipyc.py

示例7: UsingReference

# 需要導入模塊: from System.Collections import Generic [as 別名]
# 或者: from System.Collections.Generic import List [as 別名]
def UsingReference(fileName, typeName, assemblyName):
    sources = List[str]()
    sources.Add(fileName)
    pc = PythonCompiler(sources, assemblyName)
    pc.MainFile = fileName
    refAsms = List[str]()
    refAsms.Add(System.Type.GetType(typeName).Assembly.FullName)
    pc.ReferencedAssemblies = refAsms
    pc.Compile() 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:11,代碼來源:test_ipyc.py

示例8: CheckIncludeDebugInformation

# 需要導入模塊: from System.Collections import Generic [as 別名]
# 或者: from System.Collections.Generic import List [as 別名]
def CheckIncludeDebugInformation(fileName, assemblyName, include):
    sources = List[str]()
    sources.Add(fileName)
    pc = PythonCompiler(sources, assemblyName)
    pc.IncludeDebugInformation = include
    pc.Compile() 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:8,代碼來源:test_ipyc.py

示例9: PreprocessFailures

# 需要導入模塊: from System.Collections import Generic [as 別名]
# 或者: from System.Collections.Generic import List [as 別名]
def PreprocessFailures(self, fa):
		failList = List[FailureMessageAccessor](fa.GetFailureMessages() )
		for failure in failList:
			failID = failure.GetFailureDefinitionId()
			if failID == BuiltInFailures.InaccurateFailures.InaccurateLine\
			or failID == BuiltInFailures.OverlapFailures.DuplicatePoints :
				fa.DeleteWarning(failure)
		return FailureProcessingResult.Continue 
開發者ID:dimven,項目名稱:SpringNodes,代碼行數:10,代碼來源:ElementType.AdaptiveBySimpleGeometry.py

示例10: test_generic_list

# 需要導入模塊: from System.Collections import Generic [as 別名]
# 或者: from System.Collections.Generic import List [as 別名]
def test_generic_list(self):
        """https://github.com/IronLanguages/ironpython2/issues/109"""
        from System.Collections.Generic import List
        lst = List[str]()
        lst.Add('Hello')
        lst.Add('World')
        vals = []
        for v in lst[1:]:
            vals.append(v)
        self.assertEqual(vals, ['World'])
        lst.Add('Universe')
        self.assertEqual(list(lst[0::2]), ['Hello', 'Universe']) 
開發者ID:IronLanguages,項目名稱:ironpython3,代碼行數:14,代碼來源:test_list.py

示例11: PreprocessFailures

# 需要導入模塊: from System.Collections import Generic [as 別名]
# 或者: from System.Collections.Generic import List [as 別名]
def PreprocessFailures(self, failuresAccessor):
        fail_list = List[FailureMessageAccessor]()
        fail_acc_list = failuresAccessor.GetFailureMessages().GetEnumerator()
        for failure in fail_acc_list:
            failure_id = failure.GetFailureDefinitionId()
            failure_severity = failure.GetSeverity()
            failure_type = BuiltInFailures.RoomFailures.RoomNotEnclosed
            if failure_id == failure_type:
                print("{0} with id: {1} of type: RoomNotEnclosed removed!".format(failure_severity, failure_id.Guid))
                failuresAccessor.DeleteWarning(failure)
        return FailureProcessingResult.Continue


# "Start" the transaction 
開發者ID:gtalarico,項目名稱:revitapidocs.code,代碼行數:16,代碼來源:Misc_IFailuresPreprocessor.py

示例12: DrawForeground

# 需要導入模塊: from System.Collections import Generic [as 別名]
# 或者: from System.Collections.Generic import List [as 別名]
def DrawForeground(self, e):
        try:
            if self.color:
                draw = e.Display.DrawPoint
                if self.size:
                    for xyz, size, color in zip(self.points, self.size, self.color):
                        draw(Point3d(*xyz), Simple, size, color)
                else:
                    for xyz, color in zip(self.points, self.color):
                        draw(Point3d(*xyz), Simple, self._default_size, color)
            elif self.size:
                draw = e.Display.DrawPoint
                if self.color:
                    for xyz, size, color in zip(self.points, self.size, self.color):
                        draw(Point3d(*xyz), Simple, size, color)
                else:
                    for xyz, size in zip(self.points, self.size):
                        draw(Point3d(*xyz), Simple, size, self._default_color)
            else:
                points = List[Point3d](len(self.points))
                for xyz in self.points:
                    points.Add(Point3d(*xyz))
                e.Display.DrawPoints(points, Simple, self._default_size, self._default_color)
        except Exception as e:
            print(e)


# ==============================================================================
# Main
# ============================================================================== 
開發者ID:compas-dev,項目名稱:compas,代碼行數:32,代碼來源:points.py

示例13: DrawForeground

# 需要導入模塊: from System.Collections import Generic [as 別名]
# 或者: from System.Collections.Generic import List [as 別名]
def DrawForeground(self, e):
        try:
            if self.color:
                draw = e.Display.DrawLine
                if self.thickness:
                    for i, (start, end) in enumerate(self.lines):
                        draw(Point3d(*start), Point3d(*end), self.color[i], self.thickness[i])
                else:
                    for i, (start, end) in enumerate(self.lines):
                        draw(Point3d(*start), Point3d(*end), self.color[i], self._default_thickness)

            elif self.thickness:
                draw = e.Display.DrawLine
                if self.color:
                    for i, (start, end) in enumerate(self.lines):
                        draw(Point3d(*start), Point3d(*end), self.color[i], self.thickness[i])
                else:
                    for i, (start, end) in enumerate(self.lines):
                        draw(Point3d(*start), Point3d(*end), self._default_color, self.thickness[i])

            else:
                lines = List[Line](len(self.lines))
                for start, end in self.lines:
                    lines.Add(Line(Point3d(*start), Point3d(*end)))
                e.Display.DrawLines(lines, self._default_color, self._default_thickness)
        except Exception as e:
            print(e)


# ==============================================================================
# Main
# ============================================================================== 
開發者ID:compas-dev,項目名稱:compas,代碼行數:34,代碼來源:lines.py

示例14: DrawForeground

# 需要導入模塊: from System.Collections import Generic [as 別名]
# 或者: from System.Collections.Generic import List [as 別名]
def DrawForeground(self, e):
        draw_line = e.Display.DrawLine
        draw_lines = e.Display.DrawLines

        if self.color:
            if self.thickness:
                for i, start, end in self.lines:
                    draw_line(start, end, self.color[i], self.thickness[i])
            else:
                for i, start, end in self.lines:
                    draw_line(start, end, self.color[i], self._default_thickness)

        elif self.thickness:
            if self.color:
                for i, start, end in self.lines:
                    draw_line(start, end, self.color[i], self.thickness[i])
            else:
                for i, start, end in self.lines:
                    draw_line(start, end, self._default_color, self.thickness[i])

        else:
            lines = List[Line](self.mesh.number_of_edges())
            for i, start, end in self.lines:
                lines.Add(Line(start, end))
            draw_lines(lines, self._default_color, self._default_thickness)


# ==============================================================================
# Main
# ============================================================================== 
開發者ID:compas-dev,項目名稱:compas,代碼行數:32,代碼來源:mesh.py

示例15: test_safe_length_returns_length_for_net_list

# 需要導入模塊: from System.Collections import Generic [as 別名]
# 或者: from System.Collections.Generic import List [as 別名]
def test_safe_length_returns_length_for_net_list():

    a = List[Int32]()
    a.Add(1)
    a.Add(2)
    a.Add(6)

    n = safe_length(a)

    assert n==3 
開發者ID:DHI,項目名稱:mikeio,代碼行數:12,代碼來源:test_helpers.py


注:本文中的System.Collections.Generic.List方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。