随笔分类 -  Code Scrolls

摘要:一道简单数学题的最优解的程序枚举论证。 阅读全文
posted @ 2015-10-22 19:06 quanben 阅读(1782) 评论(0) 推荐(0)
摘要:An issue related to selected item update on changing data bound WPF standard ComboBox item sources I've analysed and fixed. 阅读全文
posted @ 2015-07-16 13:47 quanben 阅读(410) 评论(0) 推荐(0)
该文被密码保护。
posted @ 2015-05-28 20:24 quanben 阅读(2) 评论(0) 推荐(0)
摘要:Another stupid crap I wrote and I regret.. 阅读全文
posted @ 2014-06-03 14:40 quanben 阅读(192) 评论(0) 推荐(0)
摘要:A program that demonstrates some special values of double type and their relations. 阅读全文
posted @ 2014-03-20 18:14 quanben 阅读(206) 评论(0) 推荐(0)
摘要:This article demonstrates how the C++ new feature move constructor helps with increasing the return value passing efficiency for return value types that involve dynamically allocated contents. 阅读全文
posted @ 2013-10-03 08:38 quanben 阅读(495) 评论(0) 推荐(0)
摘要:A recently implemented enhanced wildcard string matcher implemented as part of the generic C++ template library. 阅读全文
posted @ 2013-09-21 21:22 quanben 阅读(932) 评论(0) 推荐(0)
摘要:OLE(Object Linking and Embedding) is a critical technology by Microsoft to carry out its enterprise applications, based on COM it's also a quite old one. Despite of its importance, itdoesn't seem to be so necessary to me as .NET is far more than enough. However in a recent task I have to tou 阅读全文
posted @ 2013-06-08 20:16 quanben 阅读(510) 评论(0) 推荐(0)
摘要:In C# we all know the standard way of finalising an object that potentially contains both managed and unmanaged resources islike 1 class SomeDisposabl... 阅读全文
posted @ 2013-06-07 08:01 quanben 阅读(328) 评论(0) 推荐(0)
摘要:Simplest C# code so far I can think of equivalent to the JavaScript design pattern to allow private members.The original JavaScript code can be found here:http://www.crockford.com/javascript/private.htmlFor the ease of comparison, the JavaScript code from the above linkis also pasted here, 1 functio 阅读全文
posted @ 2013-05-21 18:12 quanben 阅读(231) 评论(0) 推荐(0)
摘要:这里的基本整理一般原则是:1. 尽可能少分段2. 关于类的尽可能靠前(例如static),关于实际对象的尽可能靠后3. 早生成的尽可能靠前4. 公有的,接口的尽可能靠前5. 抽象的,通用的,基础性的,被依赖靠前;继承过来的尽量靠前6. 相对需要引起注意的尽量靠前7. 其他一些以往经验考虑 1 class Sample : BaseClass, IIntf1 2 { 3 #region Enumerations 4 5 enum EnumType 6 { 7 Const1, 8 // ... 9 } 10 11 #en... 阅读全文
posted @ 2013-04-23 09:07 quanben 阅读(556) 评论(0) 推荐(0)
摘要:Resources Needed,1. API: http://msdn.microsoft.com/en-us/library/live/hh826523.aspxlooks like the ultimateprogram has to be in a windows store app or windows phone app form, hopefully it can be an offline app in debugging mode able to have the calendar updated.2. Algorithms: (Shouldn't be too ha 阅读全文
posted @ 2013-04-09 07:32 quanben 阅读(308) 评论(0) 推荐(0)
摘要:想当然了,用递归实现DCT,没想到DCT有4个分支需要递归下去,这样的规模非但无法快速实现,反而由于本身时间复杂度没有多大减少加上递归开销等等比慢速实现往往还慢。这个代码片段将由于清洁需要从QSharp中删除而保留在这里,对其分析将在代码之后有空时进行。过两天想想是不是能用动态规划或备忘录来改进这个算法。 1 /// <summary> 2 /// Type-IV DCT implemented using recursive method 3 /// Warning: This method is mathematically crippled even slower than 阅读全文
posted @ 2013-03-26 00:36 quanben 阅读(290) 评论(0) 推荐(0)
摘要:原题出处,由July提供并解析,http://blog.csdn.net/v_july_v/article/details/8701148自己独立做,一开始方向有偏差。最后独立思路写了一个超容易出bug调了半天的O(n):目前该程序至少在1000个以1~20长度以-20.0到20.0随机浮点数为元素的随机序列上和参考算法(穷举法)对比测试通过。public static double MPCSolveQb2(this double[] seq, out int start, out int count) { start = 0; count = seq.Length; ... 阅读全文
posted @ 2013-03-24 15:21 quanben 阅读(185) 评论(0) 推荐(0)
摘要:Binary search is simple in concept but quite error-prone in implementation. Better keep one for later use. My version may look like,static int BinarySearch(TListRef list, int start, int count, const T &item, const IComparer<T> &comparer) { int low = start; int high = start + count; int 阅读全文
posted @ 2013-03-04 07:16 quanben 阅读(184) 评论(0) 推荐(0)
摘要:这里用一个算法题进行比较。原题是见http://acm.hdu.edu.cn/showproblem.php?pid=4090,登载在http://blog.csdn.net/woshi250hua/article/details/7997550作者提供了一个比较快的答案。我之前也尝试做了一个,没有用递归,但也没有用作者使用的格局保存的剪枝方案,比较慢,随后看了作者的方案后再整合进了一个基本等效的格局保存逻辑。以下是作者的C++程序的基本等价的C#程序, 1 using System.Collections.Generic; 2 3 namespace HDU4090 4 { 5 ... 阅读全文
posted @ 2012-09-22 22:29 quanben 阅读(2316) 评论(0) 推荐(0)
摘要:WPF对初学者来说一个比较复杂的概念是它用两个树来组织其元素的。了解一些WPF的同学一般都知道它们分别是逻辑树(Logical Tree)和视觉树(Visual Tree)。而这两者的关系,以及一个界面中元素究竟如何与另一个元素在这两棵树上联系起来却相当复杂,很难一言两语涵盖其规则。而树和WPF中的... 阅读全文
posted @ 2012-09-21 00:41 quanben 阅读(430) 评论(0) 推荐(0)
摘要:ADA语言内建的字符串类型是定长类型,基本接近相当于C的静态字符数组。对ADA而言,String也完全是通过字符数组的严格定义派生出来的(可参见wikibooks关于ADA类型系统的条目;关于ADA的复杂的类型系统需要另行撰文)。定长字符类型对应的操作包在Ada.Strings.Fixed中。另外String类型也有很多这个类型的Attribute。这类字符串通常在编译期决定长度(由其界限参数指定或所附值决定);但对ADA而言,这种长度确定也可以宽松一点:字符串和所有数据变量实例一样都定义在变量定义区,它可以不限定长度,而由一个函数返回的字符串确定;另一方面,对于一个子程序变量定义区的字符串, 阅读全文
posted @ 2011-11-19 18:07 quanben 阅读(456) 评论(0) 推荐(0)
摘要:ADA支持对几乎它自身的所有运算符的重载,虽然ADA的运算符系统不像C/C++那样庞大灵活,ADA提供这种重载某种意义上说是为了达到作为对象操作的一致性要求,这也理应是运算符重载的目的。由于ADA本身的运算符定义特征,所有运算符都是单目或双目的,而ADA将他们均看成函数(function),其参数是输入性(in)对象类型,输出是这种对象类型。以下是一般用来阐释运算符重载的经典方法之一,复数的定义和运算。其实ADA本身也提供了复数的泛型模板,但是这里的小例子强调一些ADA的语言特征。比如ADA本身提供的复数泛型只支持数值类型作为复数分量,而这里采用了任何类型。复数定义文件(complex.ads 阅读全文
posted @ 2011-11-19 10:42 quanben 阅读(372) 评论(0) 推荐(0)
摘要:普通的ADA并不含有垃圾收集等托管程序的特性,除非当ADA的目标运行时建立在Java Virtual Machine或.NET系统上。所以从这个对象内存分配角度,ADA和C++基本上是等价的。ADA提供的语言特性,基本上足以使得ADA能够实现智能指针。当然,是不是有必要在ADA中使用智能指针(考虑ADA常用的思考建模方式),其完善程度(指针的类型,对于OO的支持和对于一般数据的支持)又是另一会儿事。智能指针再智能也不能达到托管程序所能达到内存管理功能(例如简单的引用计数是无法应对孤立环路结构的释放的)。当然,纯粹展现一下ADA的语言特性,这不失为一个好的例子。首先是声明(autoptr.ads 阅读全文
posted @ 2011-11-16 22:28 quanben 阅读(473) 评论(0) 推荐(0)