本文介绍了.GetProperties的BIG-O()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 如果有n个属性,然后是.GetProperties 0的大O(n)或在有参与反映,增加了复杂流程?If there are n properties, then is the Big-O of .GetProperties O(n) or are there are processes involved in the reflection that add complexity?说有这个定义的类:public class Reflector{ public string name { get; set; } public int number { get; set; } public bool flag { get; set; } public List<string> etc { get; set; }}和则调用该函数:var reflect = new Reflector();PropertyInfo[] properties = reflect.GetType().GetProperties(); 什么是时间复杂度,也就是大澳, .GetProperties的( )?考虑到有4个属性,这将只需要4次迭代或者是比这更复杂?或者说,它是O(1)用一些标准的复杂性去的名单 - 这似乎仍然必须是O(N)刚刚建立的属性阵列What is the time complexity, i.e. Big-O, of .GetProperties()? Considering that there are 4 properties, would this only take 4 iterations or is it more complex than that? Or, is it O(1) with some standard set of complexity to get to the list - which seems it must still be O(n) just to build the properties array?推荐答案大O约渐近复杂性,换句话说,O(n)是仅适用于的较大值的N个。 类将永远不会有足够的性能使这种相关性。Big-O is about asymptotic complexity, in other words O(n) is only relevant for large values of n.A class will never have enough properties to make this relevant.有关实用的目的,您不妨考虑一下它O(1),但有一个非常大的常数。For practical purposes, you might as well consider it O(1), but with a very big constant.这样的问题,以纳秒,没有大O符号表示。This kind of issue is expressed in nanoseconds, not Big-O notations. 这篇关于.GetProperties的BIG-O()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-20 02:49