<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Jnvarava</id>
	<title>Expertiza_Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Jnvarava"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Jnvarava"/>
	<updated>2026-07-13T23:04:01Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6c_sj&amp;diff=55498</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6c sj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6c_sj&amp;diff=55498"/>
		<updated>2011-11-17T17:26:32Z</updated>

		<summary type="html">&lt;p&gt;Jnvarava: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Generic Programming==&lt;br /&gt;
&amp;lt;p&amp;gt;Generic programming is a style of computer programming in which algorithms are written in terms of &amp;lt;i&amp;gt;to-be-specified-later&amp;lt;/i&amp;gt; types that are then instantiated when needed for specific types provided as parameters. This enables writing common set of functions which differ only in the types on which they operate. This reduces duplication. Software entities created using generic programming are known as ''generics'' in [http://en.wikipedia.org/wiki/Ada_(programming_language) Ada], [http://en.wikipedia.org/wiki/Eiffel_(programming_language) Eiffel], [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/F_Sharp_(programming_language) F#], and [http://en.wikipedia.org/wiki/Visual_Basic_.NET Visual Basic .NET]; parametric polymorphism in [http://en.wikipedia.org/wiki/ML_(programming_language) ML], [http://en.wikipedia.org/wiki/Scala_(programming_language Scala] and [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/template_(programming) template]s in [http://en.wikipedia.org/wiki/C++ C++].&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;For example, given various data structures and several algorithms, the brute force way would be implement them for each data structure which would mean that various combinations of implementations will be necessary. Generic programming reduces this effort.&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Generics in Java==&lt;br /&gt;
===What are Generics?===&lt;br /&gt;
Generics were added to Java programming language as a part of J2SE 5.0 release in 2004. They allow programmers to develop generic and compile safe applications which enables a type or method to operate on objects of various type. This feature is well utilized while implementing [http://en.wikipedia.org/wiki/Java_Collections Java Collections]. The reason why people went into generic programming can be well explained using the below example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  List list = new ArrayList();&lt;br /&gt;
  list.add(&amp;quot;name&amp;quot;);&lt;br /&gt;
  Integer num = (Integer)list.get(0);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In this example, we insert a &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt; into an &amp;lt;code&amp;gt;ArrayList&amp;lt;/code&amp;gt; and retrieve element by typecasting with Integer wrapper class. This throws a runtime exception because of Illegal class cast. But if we use generics, runtime exceptions can be avoided and the compiler will be able to catch such issues which in turn help a programmer to build a bug free code. So if we convert the above code to use generic then it would look like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  List&amp;lt;String&amp;gt; list = new ArrayList&amp;lt;String&amp;gt;();&lt;br /&gt;
  list.add(&amp;quot;name&amp;quot;);&lt;br /&gt;
  Integer num = list.get(0); //line 1 &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here at line 1 the compiler throws an error because the compiler on seeing the declaration of ArrayList will be expecting the list to have just &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt; and thereby the return type of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; to be &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Implementing Generics:===&lt;br /&gt;
Java provides a feature which helps one to implement your own generic types and this will help to build more sophisticated and runtime error free applications. Consider the below example:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
   interface List&amp;lt;N&amp;gt; {&lt;br /&gt;
                         void add(N i);&lt;br /&gt;
                         Iterator&amp;lt;N&amp;gt; iterator();&lt;br /&gt;
                      }&lt;br /&gt;
   interface Iterator&amp;lt;N&amp;gt; {&lt;br /&gt;
                            N next();&lt;br /&gt;
                            boolean hasNext();&lt;br /&gt;
                         }&lt;br /&gt;
   class LinkedList&amp;lt;N&amp;gt; implements List&amp;lt;N&amp;gt; {&lt;br /&gt;
                          //Business Logic   &lt;br /&gt;
                 }&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
So here, &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt; can be replaced with any primitive data types or wrapper classes in the business logic. But we need to make sure that placeholders to be replaced with valid subtypes of Object. Generics implementation is not restricted for classes or interfaces, we can have for static/non static methods and constructors.&lt;br /&gt;
&lt;br /&gt;
Example for generic methods:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;T&amp;gt; void fromArrayToCollection(T[] a, Collection&amp;lt;T&amp;gt; c) {&lt;br /&gt;
    for (T o : a) {&lt;br /&gt;
        c.add(o); // Correct&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Pros and Cons===&lt;br /&gt;
&amp;lt;b&amp;gt;Pros:&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Reduces the number of casts in the program, which in turn reduces the number of potential bugs in the program.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Improves code clarity and maintenance.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Cons:&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Parameter type information is not available at run time.&amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;li&amp;gt;The automatically generated casts may fail when interoperating with ill-behaved legacy code.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Templates in C++==&lt;br /&gt;
===What are templates?===&lt;br /&gt;
&amp;lt;p&amp;gt;Templates are functions that can operate with &amp;lt;i&amp;gt;generic types&amp;lt;/i&amp;gt; which means that the functionality can be adapted for more than one type of data without repeating the entire code for each type. &lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
===Overview===&lt;br /&gt;
Templates can be either function templates or class templates.&lt;br /&gt;
====Function Templates====&lt;br /&gt;
These are just like regular functions except that they can have arguments of different types. A single function definition works with different kinds of data types. During compile time, the actual functions are generated once the compiler knows the data type being used. This kind of template does not save any memory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Example&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
template &amp;lt;typename Type&amp;gt;&lt;br /&gt;
Type max(Type a, Type b) {&lt;br /&gt;
    return a &amp;gt; b ? a : b;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
  // This will call max &amp;lt;int&amp;gt; (by argument deduction)&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; max(3, 7) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  // This will call max&amp;lt;double&amp;gt; (by argument deduction)&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; max(3.0, 7.0) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  // This type is ambiguous, so explicitly instantiate max&amp;lt;double&amp;gt;&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; max&amp;lt;double&amp;gt;(3, 7.0) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Class Templates====&lt;br /&gt;
A class template provides a specification for generating classes based on parameters. A class template is instantiated by passing a given set of types to it as template arguments.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Example&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
template &amp;lt;class T&amp;gt;&lt;br /&gt;
class mypair {&lt;br /&gt;
    T values [2];&lt;br /&gt;
  public:&lt;br /&gt;
    mypair (T first, T second)&lt;br /&gt;
    {&lt;br /&gt;
      values[0]=first; values[1]=second;&lt;br /&gt;
    }&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Features of C++ Templates===&lt;br /&gt;
Some of the features of C++ templates are:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Implemented in the compiler.&amp;lt;ol&amp;gt;&amp;lt;ul&amp;gt;No runtime overhead&amp;lt;/ul&amp;gt;&amp;lt;ul&amp;gt;Requires template source to be in headers&amp;lt;/ul&amp;gt;&amp;lt;ul&amp;gt;Latent typing means template instantiator does no type checking&amp;lt;/ul&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Gloriﬁed macro facility&amp;lt;ol&amp;gt;&amp;lt;ul&amp;gt;“Macros done right”/“Macros that look like classes”&amp;lt;/ul&amp;gt;&amp;lt;/ol&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Can use template arguments for both classes and straight function&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Template specialization&amp;lt;ol&amp;gt;&amp;lt;ul&amp;gt;Speciﬁc implementation of a templated type or method&amp;lt;/ul&amp;gt;&amp;lt;/ol&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Pattern matching and text replacement&amp;lt;ol&amp;gt;&amp;lt;ul&amp;gt;Declarative model (like [http://en.wikipedia.org/wiki/Prolog Prolog])&amp;lt;/ul&amp;gt;&amp;lt;/ol&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Pros and Cons===&lt;br /&gt;
Usage of templates have both advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Pros&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Reduction in code size.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;They are type-safe, that is, type-checking is done at compile time.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Cons&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Since all compilers are not good at their support for templates, they may not be very portable.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Compilers generate additional code for each template type, this could lead to huge code if usage of templates is not checked.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Information hiding is not achieved as the code is all exposed in the header.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Evolution of Generics==&lt;br /&gt;
Here we take Java programming language as an example to explain evolution of generics. Generics were introduced with Java 1.5. However, before that, the codes were bulky and messy but the results were same. Rather than simply using a List&amp;lt;Integer&amp;gt; or Comparable&amp;lt;String&amp;gt;, developers had to deal with a significant amount of inheritance, casting, and instanceof testing. For example, an ArrayList to store only Integers pre-generics might look like the below snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public class IntegerList extends ArrayList{&lt;br /&gt;
     public boolean add(Object o){&lt;br /&gt;
            if(o instanceof Integer)&lt;br /&gt;
                return super.add(o);&lt;br /&gt;
             return false;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
      public Integer get(int index){&lt;br /&gt;
           return (Integer)super.get(index);&lt;br /&gt;
      }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Generics allows to write more modular and reusable code that is adaptable to various datatypes, yet logically restrictive as well. Currently, generics are implemented using erasure, which means that the generic type information is not available at runtime, which makes some kind of code hard to write. Generics were implemented this way to support backwards compatibility with older non-generic code. Reified generics would make the generic type information available at runtime, which would break legacy non-generic code. Generics are implemented using erasure, in which generic type parameters are simply removed at runtime. That doesn't render generics useless, because you get typechecking at compile-time based on the generic type parameters, and also because the compiler inserts casts in the code based on the type parameters.&lt;br /&gt;
===Erasure v/s Reification===&lt;br /&gt;
&lt;br /&gt;
Consider the below example, it won't work because of erasure.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public class Test&amp;lt;Key, Val&amp;gt; {&lt;br /&gt;
  public void test(Key key) {&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
  public void test(Val value) {&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This would give a name clash error for having same erasure and one way to avoid the error is by renaming the method name but this will not the serve the purpose of overloading. Similarly, the below example would give errors because the JVM is not aware of the type T instead views it just as an Object.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public class Test {&lt;br /&gt;
  public &amp;lt;T&amp;gt; void f() {&lt;br /&gt;
    T t = new T();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
So reified generics have support in the compiler for preserving type information whereas type erased generics don't have and that &amp;quot;remember&amp;quot; the class they were created with during runtime. Below are some of the reasons why Java should have reified generics:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Type argument erasure cripples frameworks that works with generic types and this results in horrid workarounds&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Reified generics allows Typesafe narrowing. Currently in Java, we first test the type of the object using the instanceof operator, and then attempt to downcast it using a C-style typecast&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Interoperability between statically-typed is difficult since few support reified generics.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But at the same time reified generics have issues and one of the main concern is incompatible with the current collections. So a test on &amp;lt;code&amp;gt;instanceof List&amp;lt;String&amp;gt;&amp;lt;/code&amp;gt; would now test that the object is an instance of &amp;lt;code&amp;gt;List&amp;lt;/code&amp;gt; but also that its elements are of type &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt;. This requires a lot of work around since we need to distinguish between collections making used of reified types from their older types.&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;http://en.wikipedia.org/wiki/Generic_programming&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://en.wikipedia.org/wiki/Generics_in_Java&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://www.oracle.com/technetwork/articles/javase/generics-136597.html&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://download.oracle.com/javase/tutorial/extra/generics/methods.html&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://www.cplusplus.com/doc/tutorial/templates/&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://en.wikipedia.org/wiki/Template_(programming)&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://www.cs.binghamton.edu/~mike/presentations/java-generics-cs580c-fall-2007.pdf&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://jnb.ociweb.com/jnb/jnbJul2003.html&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://tech.puredanger.com/java7/#reified&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://gafter.blogspot.com/2006/11/reified-generics-for-java.html&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://relation.to/21406.lace&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://beust.com/weblog/2011/07/29/erasure-vs-reification/&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jnvarava</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6c_sj&amp;diff=55497</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6c sj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6c_sj&amp;diff=55497"/>
		<updated>2011-11-17T17:25:36Z</updated>

		<summary type="html">&lt;p&gt;Jnvarava: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Generic Programming==&lt;br /&gt;
&amp;lt;p&amp;gt;Generic programming is a style of computer programming in which algorithms are written in terms of &amp;lt;i&amp;gt;to-be-specified-later&amp;lt;/i&amp;gt; types that are then instantiated when needed for specific types provided as parameters. This enables writing common set of functions which differ only in the types on which they operate. This reduces duplication. Software entities created using generic programming are known as ''generics'' in [http://en.wikipedia.org/wiki/Ada_(programming_language) Ada], [http://en.wikipedia.org/wiki/Eiffel_(programming_language) Eiffel], [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/F_Sharp_(programming_language) F#], and [http://en.wikipedia.org/wiki/Visual_Basic_.NET Visual Basic .NET]; parametric polymorphism in [http://en.wikipedia.org/wiki/ML_(programming_language) ML], [http://en.wikipedia.org/wiki/Scala_(programming_language Scala] and [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/template_(programming) template]s in [http://en.wikipedia.org/wiki/C++ C++].&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;For example, given various data structures and several algorithms, the brute force way would be implement them for each data structure which would mean that various combinations of implementations will be necessary. Generic programming reduces this effort.&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Generics in Java==&lt;br /&gt;
===What are Generics?===&lt;br /&gt;
Generics were added to Java programming language as a part of J2SE 5.0 release in 2004. They allow programmers to develop generic and compile safe applications which enables a type or method to operate on objects of various type. This feature is well utilized while implementing [http://en.wikipedia.org/wiki/Java_Collections Java Collections]. The reason why people went into generic programming can be well explained using the below example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  List list = new ArrayList();&lt;br /&gt;
  list.add(&amp;quot;name&amp;quot;);&lt;br /&gt;
  Integer num = (Integer)list.get(0);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In this example, we insert a &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt; into an &amp;lt;code&amp;gt;ArrayList&amp;lt;/code&amp;gt; and retrieve element by typecasting with Integer wrapper class. This throws a runtime exception because of Illegal class cast. But if we use generics, runtime exceptions can be avoided and the compiler will be able to catch such issues which in turn help a programmer to build a bug free code. So if we convert the above code to use generic then it would look like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  List&amp;lt;String&amp;gt; list = new ArrayList&amp;lt;String&amp;gt;();&lt;br /&gt;
  list.add(&amp;quot;name&amp;quot;);&lt;br /&gt;
  Integer num = list.get(0); //line 1 &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here at line 1 the compiler throws an error because the compiler on seeing the declaration of ArrayList will be expecting the list to have just &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt; and thereby the return type of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; to be &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Implementing Generics:===&lt;br /&gt;
Java provides a feature which helps one to implement your own generic types and this will help to build more sophisticated and runtime error free applications. Consider the below example:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
   interface List&amp;lt;N&amp;gt; {&lt;br /&gt;
                         void add(N i);&lt;br /&gt;
                         Iterator&amp;lt;N&amp;gt; iterator();&lt;br /&gt;
                      }&lt;br /&gt;
   interface Iterator&amp;lt;N&amp;gt; {&lt;br /&gt;
                            N next();&lt;br /&gt;
                            boolean hasNext();&lt;br /&gt;
                         }&lt;br /&gt;
   class LinkedList&amp;lt;N&amp;gt; implements List&amp;lt;N&amp;gt; {&lt;br /&gt;
                          //Business Logic   &lt;br /&gt;
                 }&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
So here, &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt; can be replaced with any primitive data types or wrapper classes in the business logic. But we need to make sure that placeholders to be replaced with valid subtypes of Object. Generics implementation is not restricted for classes or interfaces, we can have for static/non static methods and constructors.&lt;br /&gt;
&lt;br /&gt;
Example for generic methods:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;T&amp;gt; void fromArrayToCollection(T[] a, Collection&amp;lt;T&amp;gt; c) {&lt;br /&gt;
    for (T o : a) {&lt;br /&gt;
        c.add(o); // Correct&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Pros and Cons===&lt;br /&gt;
&amp;lt;b&amp;gt;Pros:&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Reduces the number of casts in the program, which in turn reduces the number of potential bugs in the program.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Improves code clarity and maintenance.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Cons:&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Parameter type information is not available at run time.&amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;li&amp;gt;The automatically generated casts may fail when interoperating with ill-behaved legacy code.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Templates in C++==&lt;br /&gt;
===What are templates?===&lt;br /&gt;
&amp;lt;p&amp;gt;Templates are functions that can operate with &amp;lt;i&amp;gt;generic types&amp;lt;/i&amp;gt; which means that the functionality can be adapted for more than one type of data without repeating the entire code for each type. &lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
===Overview===&lt;br /&gt;
Templates can be either function templates or class templates.&lt;br /&gt;
====Function Templates====&lt;br /&gt;
These are just like regular functions except that they can have arguments of different types. A single function definition works with different kinds of data types. During compile time, the actual functions are generated once the compiler knows the data type being used. This kind of template does not save any memory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Example&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
template &amp;lt;typename Type&amp;gt;&lt;br /&gt;
Type max(Type a, Type b) {&lt;br /&gt;
    return a &amp;gt; b ? a : b;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
  // This will call max &amp;lt;int&amp;gt; (by argument deduction)&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; max(3, 7) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  // This will call max&amp;lt;double&amp;gt; (by argument deduction)&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; max(3.0, 7.0) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  // This type is ambiguous, so explicitly instantiate max&amp;lt;double&amp;gt;&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; max&amp;lt;double&amp;gt;(3, 7.0) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Class Templates====&lt;br /&gt;
A class template provides a specification for generating classes based on parameters. A class template is instantiated by passing a given set of types to it as template arguments.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Example&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
template &amp;lt;class T&amp;gt;&lt;br /&gt;
class mypair {&lt;br /&gt;
    T values [2];&lt;br /&gt;
  public:&lt;br /&gt;
    mypair (T first, T second)&lt;br /&gt;
    {&lt;br /&gt;
      values[0]=first; values[1]=second;&lt;br /&gt;
    }&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Features of C++ Templates===&lt;br /&gt;
Some of the features of C++ templates are:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Implemented in the compiler.&amp;lt;ol&amp;gt;&amp;lt;ul&amp;gt;No runtime overhead&amp;lt;/ul&amp;gt;&amp;lt;ul&amp;gt;Requires template source to be in headers&amp;lt;/ul&amp;gt;&amp;lt;ul&amp;gt;Latent typing means template instantiator does no type checking&amp;lt;/ul&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Gloriﬁed macro facility&amp;lt;ol&amp;gt;&amp;lt;ul&amp;gt;“Macros done right”/“Macros that look like classes”&amp;lt;/ul&amp;gt;&amp;lt;/ol&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Can use template arguments for both classes and straight function&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Template specialization&amp;lt;ol&amp;gt;&amp;lt;ul&amp;gt;Speciﬁc implementation of a templated type or method&amp;lt;/ul&amp;gt;&amp;lt;/ol&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Pattern matching and text replacement&amp;lt;ol&amp;gt;&amp;lt;ul&amp;gt;Declarative model (like [http://en.wikipedia.org/wiki/Prolog Prolog])&amp;lt;/ul&amp;gt;&amp;lt;/ol&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Pros and Cons===&lt;br /&gt;
Usage of templates have both advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Pros&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Reduction in code size.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;They are type-safe, that is, type-checking is done at compile time.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Cons&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Since all compilers are not good at their support for templates, they may not be very portable.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Compilers generate additional code for each template type, this could lead to huge code if usage of templates is not checked.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Information hiding is not achieved as the code is all exposed in the header.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Evolution of Generics===&lt;br /&gt;
Here we take Java programming language as an example to explain evolution of generics. Generics were introduced with Java 1.5. However, before that, the codes were bulky and messy but the results were same. Rather than simply using a List&amp;lt;Integer&amp;gt; or Comparable&amp;lt;String&amp;gt;, developers had to deal with a significant amount of inheritance, casting, and instanceof testing. For example, an ArrayList to store only Integers pre-generics might look like the below snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public class IntegerList extends ArrayList{&lt;br /&gt;
     public boolean add(Object o){&lt;br /&gt;
            if(o instanceof Integer)&lt;br /&gt;
                return super.add(o);&lt;br /&gt;
             return false;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
      public Integer get(int index){&lt;br /&gt;
           return (Integer)super.get(index);&lt;br /&gt;
      }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Generics allows to write more modular and reusable code that is adaptable to various datatypes, yet logically restrictive as well. Currently, generics are implemented using erasure, which means that the generic type information is not available at runtime, which makes some kind of code hard to write. Generics were implemented this way to support backwards compatibility with older non-generic code. Reified generics would make the generic type information available at runtime, which would break legacy non-generic code. Generics are implemented using erasure, in which generic type parameters are simply removed at runtime. That doesn't render generics useless, because you get typechecking at compile-time based on the generic type parameters, and also because the compiler inserts casts in the code based on the type parameters.&lt;br /&gt;
==Erasure v/s Reification==&lt;br /&gt;
&lt;br /&gt;
Consider the below example, it won't work because of erasure.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public class Test&amp;lt;Key, Val&amp;gt; {&lt;br /&gt;
  public void test(Key key) {&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
  public void test(Val value) {&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This would give a name clash error for having same erasure and one way to avoid the error is by renaming the method name but this will not the serve the purpose of overloading. Similarly, the below example would give errors because the JVM is not aware of the type T instead views it just as an Object.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public class Test {&lt;br /&gt;
  public &amp;lt;T&amp;gt; void f() {&lt;br /&gt;
    T t = new T();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
So reified generics have support in the compiler for preserving type information whereas type erased generics don't have and that &amp;quot;remember&amp;quot; the class they were created with during runtime. Below are some of the reasons why Java should have reified generics:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Type argument erasure cripples frameworks that works with generic types and this results in horrid workarounds&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Reified generics allows Typesafe narrowing. Currently in Java, we first test the type of the object using the instanceof operator, and then attempt to downcast it using a C-style typecast&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Interoperability between statically-typed is difficult since few support reified generics.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But at the same time reified generics have issues and one of the main concern is incompatible with the current collections. So a test on &amp;lt;code&amp;gt;instanceof List&amp;lt;String&amp;gt;&amp;lt;/code&amp;gt; would now test that the object is an instance of &amp;lt;code&amp;gt;List&amp;lt;/code&amp;gt; but also that its elements are of type &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt;. This requires a lot of work around since we need to distinguish between collections making used of reified types from their older types.&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;http://en.wikipedia.org/wiki/Generic_programming&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://en.wikipedia.org/wiki/Generics_in_Java&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://www.oracle.com/technetwork/articles/javase/generics-136597.html&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://download.oracle.com/javase/tutorial/extra/generics/methods.html&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://www.cplusplus.com/doc/tutorial/templates/&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://en.wikipedia.org/wiki/Template_(programming)&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://www.cs.binghamton.edu/~mike/presentations/java-generics-cs580c-fall-2007.pdf&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://jnb.ociweb.com/jnb/jnbJul2003.html&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://tech.puredanger.com/java7/#reified&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://gafter.blogspot.com/2006/11/reified-generics-for-java.html&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://relation.to/21406.lace&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://beust.com/weblog/2011/07/29/erasure-vs-reification/&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jnvarava</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6c_sj&amp;diff=55496</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6c sj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6c_sj&amp;diff=55496"/>
		<updated>2011-11-17T17:24:05Z</updated>

		<summary type="html">&lt;p&gt;Jnvarava: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Generic Programming==&lt;br /&gt;
&amp;lt;p&amp;gt;Generic programming is a style of computer programming in which algorithms are written in terms of &amp;lt;i&amp;gt;to-be-specified-later&amp;lt;/i&amp;gt; types that are then instantiated when needed for specific types provided as parameters. This enables writing common set of functions which differ only in the types on which they operate. This reduces duplication. Software entities created using generic programming are known as ''generics'' in [http://en.wikipedia.org/wiki/Ada_(programming_language) Ada], [http://en.wikipedia.org/wiki/Eiffel_(programming_language) Eiffel], [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/F_Sharp_(programming_language) F#], and [http://en.wikipedia.org/wiki/Visual_Basic_.NET Visual Basic .NET]; parametric polymorphism in [http://en.wikipedia.org/wiki/ML_(programming_language) ML], [http://en.wikipedia.org/wiki/Scala_(programming_language Scala] and [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/template_(programming) template]s in [http://en.wikipedia.org/wiki/C++ C++].&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;For example, given various data structures and several algorithms, the brute force way would be implement them for each data structure which would mean that various combinations of implementations will be necessary. Generic programming reduces this effort.&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Generics in Java==&lt;br /&gt;
===What are Generics?===&lt;br /&gt;
Generics were added to Java programming language as a part of J2SE 5.0 release in 2004. They allow programmers to develop generic and compile safe applications which enables a type or method to operate on objects of various type. This feature is well utilized while implementing [http://en.wikipedia.org/wiki/Java_Collections Java Collections]. The reason why people went into generic programming can be well explained using the below example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  List list = new ArrayList();&lt;br /&gt;
  list.add(&amp;quot;name&amp;quot;);&lt;br /&gt;
  Integer num = (Integer)list.get(0);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In this example, we insert a &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt; into an &amp;lt;code&amp;gt;ArrayList&amp;lt;/code&amp;gt; and retrieve element by typecasting with Integer wrapper class. This throws a runtime exception because of Illegal class cast. But if we use generics, runtime exceptions can be avoided and the compiler will be able to catch such issues which in turn help a programmer to build a bug free code. So if we convert the above code to use generic then it would look like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  List&amp;lt;String&amp;gt; list = new ArrayList&amp;lt;String&amp;gt;();&lt;br /&gt;
  list.add(&amp;quot;name&amp;quot;);&lt;br /&gt;
  Integer num = list.get(0); //line 1 &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here at line 1 the compiler throws an error because the compiler on seeing the declaration of ArrayList will be expecting the list to have just &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt; and thereby the return type of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; to be &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Implementing Generics:===&lt;br /&gt;
Java provides a feature which helps one to implement your own generic types and this will help to build more sophisticated and runtime error free applications. Consider the below example:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
   interface List&amp;lt;N&amp;gt; {&lt;br /&gt;
                         void add(N i);&lt;br /&gt;
                         Iterator&amp;lt;N&amp;gt; iterator();&lt;br /&gt;
                      }&lt;br /&gt;
   interface Iterator&amp;lt;N&amp;gt; {&lt;br /&gt;
                            N next();&lt;br /&gt;
                            boolean hasNext();&lt;br /&gt;
                         }&lt;br /&gt;
   class LinkedList&amp;lt;N&amp;gt; implements List&amp;lt;N&amp;gt; {&lt;br /&gt;
                          //Business Logic   &lt;br /&gt;
                 }&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
So here, &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt; can be replaced with any primitive data types or wrapper classes in the business logic. But we need to make sure that placeholders to be replaced with valid subtypes of Object. Generics implementation is not restricted for classes or interfaces, we can have for static/non static methods and constructors.&lt;br /&gt;
&lt;br /&gt;
Example for generic methods:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;T&amp;gt; void fromArrayToCollection(T[] a, Collection&amp;lt;T&amp;gt; c) {&lt;br /&gt;
    for (T o : a) {&lt;br /&gt;
        c.add(o); // Correct&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Pros and Cons===&lt;br /&gt;
&amp;lt;b&amp;gt;Pros:&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Reduces the number of casts in the program, which in turn reduces the number of potential bugs in the program.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Improves code clarity and maintenance.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Cons:&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Parameter type information is not available at run time.&amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;li&amp;gt;The automatically generated casts may fail when interoperating with ill-behaved legacy code.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Templates in C++==&lt;br /&gt;
===What are templates?===&lt;br /&gt;
&amp;lt;p&amp;gt;Templates are functions that can operate with &amp;lt;i&amp;gt;generic types&amp;lt;/i&amp;gt; which means that the functionality can be adapted for more than one type of data without repeating the entire code for each type. &lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
===Overview===&lt;br /&gt;
Templates can be either function templates or class templates.&lt;br /&gt;
====Function Templates====&lt;br /&gt;
These are just like regular functions except that they can have arguments of different types. A single function definition works with different kinds of data types. During compile time, the actual functions are generated once the compiler knows the data type being used. This kind of template does not save any memory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Example&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
template &amp;lt;typename Type&amp;gt;&lt;br /&gt;
Type max(Type a, Type b) {&lt;br /&gt;
    return a &amp;gt; b ? a : b;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
  // This will call max &amp;lt;int&amp;gt; (by argument deduction)&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; max(3, 7) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  // This will call max&amp;lt;double&amp;gt; (by argument deduction)&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; max(3.0, 7.0) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  // This type is ambiguous, so explicitly instantiate max&amp;lt;double&amp;gt;&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; max&amp;lt;double&amp;gt;(3, 7.0) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Class Templates====&lt;br /&gt;
A class template provides a specification for generating classes based on parameters. A class template is instantiated by passing a given set of types to it as template arguments.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Example&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
template &amp;lt;class T&amp;gt;&lt;br /&gt;
class mypair {&lt;br /&gt;
    T values [2];&lt;br /&gt;
  public:&lt;br /&gt;
    mypair (T first, T second)&lt;br /&gt;
    {&lt;br /&gt;
      values[0]=first; values[1]=second;&lt;br /&gt;
    }&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Features of C++ Templates===&lt;br /&gt;
Some of the features of C++ templates are:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Implemented in the compiler.&amp;lt;ol&amp;gt;&amp;lt;ul&amp;gt;No runtime overhead&amp;lt;/ul&amp;gt;&amp;lt;ul&amp;gt;Requires template source to be in headers&amp;lt;/ul&amp;gt;&amp;lt;ul&amp;gt;Latent typing means template instantiator does no type checking&amp;lt;/ul&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Gloriﬁed macro facility&amp;lt;ol&amp;gt;&amp;lt;ul&amp;gt;“Macros done right”/“Macros that look like classes”&amp;lt;/ul&amp;gt;&amp;lt;/ol&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Can use template arguments for both classes and straight function&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Template specialization&amp;lt;ol&amp;gt;&amp;lt;ul&amp;gt;Speciﬁc implementation of a templated type or method&amp;lt;/ul&amp;gt;&amp;lt;/ol&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Pattern matching and text replacement&amp;lt;ol&amp;gt;&amp;lt;ul&amp;gt;Declarative model (like [http://en.wikipedia.org/wiki/Prolog Prolog])&amp;lt;/ul&amp;gt;&amp;lt;/ol&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Pros and Cons===&lt;br /&gt;
Usage of templates have both advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Pros&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Reduction in code size.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;They are type-safe, that is, type-checking is done at compile time.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Cons&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Since all compilers are not good at their support for templates, they may not be very portable.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Compilers generate additional code for each template type, this could lead to huge code if usage of templates is not checked.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Information hiding is not achieved as the code is all exposed in the header.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Evolution of Generics==&lt;br /&gt;
Here we take Java programming language as an example to explain evolution of generics. Generics were introduced with Java 1.5. However, before that, the codes were bulky and messy but the results were same. Rather than simply using a List&amp;lt;Integer&amp;gt; or Comparable&amp;lt;String&amp;gt;, developers had to deal with a significant amount of inheritance, casting, and instanceof testing. For example, an ArrayList to store only Integers pre-generics might look like the below snippet:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public class IntegerList extends ArrayList{&lt;br /&gt;
     public boolean add(Object o){&lt;br /&gt;
            if(o instanceof Integer)&lt;br /&gt;
                return super.add(o);&lt;br /&gt;
             return false;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
      public Integer get(int index){&lt;br /&gt;
           return (Integer)super.get(index);&lt;br /&gt;
      }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Generics allows to write more modular and reusable code that is adaptable to various datatypes, yet logically restrictive as well. Currently, generics are implemented using erasure, which means that the generic type information is not available at runtime, which makes some kind of code hard to write. Generics were implemented this way to support backwards compatibility with older non-generic code. Reified generics would make the generic type information available at runtime, which would break legacy non-generic code. Generics are implemented using erasure, in which generic type parameters are simply removed at runtime. That doesn't render generics useless, because you get typechecking at compile-time based on the generic type parameters, and also because the compiler inserts casts in the code based on the type parameters.&lt;br /&gt;
==Erasure v/s Reification==&lt;br /&gt;
&lt;br /&gt;
Consider the below example, it won't work because of erasure.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public class Test&amp;lt;Key, Val&amp;gt; {&lt;br /&gt;
  public void test(Key key) {&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
  public void test(Val value) {&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This would give a name clash error for having same erasure and one way to avoid the error is by renaming the method name but this will not the serve the purpose of overloading. Similarly, the below example would give errors because the JVM is not aware of the type T instead views it just as an Object.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public class Test {&lt;br /&gt;
  public &amp;lt;T&amp;gt; void f() {&lt;br /&gt;
    T t = new T();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
So reified generics have support in the compiler for preserving type information whereas type erased generics don't have and that &amp;quot;remember&amp;quot; the class they were created with during runtime. Below are some of the reasons why Java should have reified generics:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Type argument erasure cripples frameworks that works with generic types and this results in horrid workarounds&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Reified generics allows Typesafe narrowing. Currently in Java, we first test the type of the object using the instanceof operator, and then attempt to downcast it using a C-style typecast&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Interoperability between statically-typed is difficult since few support reified generics.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But at the same time reified generics have issues and one of the main concern is incompatible with the current collections. So a test on instanceof List&amp;lt;String&amp;gt; would now test that the object is an instance of List but also that its elements are of type String. This requires a lot of work around since we need to distinguish between collections making used of reified types from their older types.&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;http://en.wikipedia.org/wiki/Generic_programming&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://en.wikipedia.org/wiki/Generics_in_Java&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://www.oracle.com/technetwork/articles/javase/generics-136597.html&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://download.oracle.com/javase/tutorial/extra/generics/methods.html&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://www.cplusplus.com/doc/tutorial/templates/&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://en.wikipedia.org/wiki/Template_(programming)&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://www.cs.binghamton.edu/~mike/presentations/java-generics-cs580c-fall-2007.pdf&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://jnb.ociweb.com/jnb/jnbJul2003.html&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://tech.puredanger.com/java7/#reified&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://gafter.blogspot.com/2006/11/reified-generics-for-java.html&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://relation.to/21406.lace&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://beust.com/weblog/2011/07/29/erasure-vs-reification/&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jnvarava</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6c_sj&amp;diff=55488</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6c sj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6c_sj&amp;diff=55488"/>
		<updated>2011-11-17T15:55:32Z</updated>

		<summary type="html">&lt;p&gt;Jnvarava: /* Pros and Cons */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Generic Programming==&lt;br /&gt;
&amp;lt;p&amp;gt;Generic programming is a style of computer programming in which algorithms are written in terms of &amp;lt;i&amp;gt;to-be-specified-later&amp;lt;/i&amp;gt; types that are then instantiated when needed for specific types provided as parameters. This enables writing common set of functions which differ only in the types on which they operate. This reduces duplication. Software entities created using generic programming are known as ''generics'' in [http://en.wikipedia.org/wiki/Ada_(programming_language) Ada], [http://en.wikipedia.org/wiki/Eiffel_(programming_language) Eiffel], [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/F_Sharp_(programming_language) F#], and [http://en.wikipedia.org/wiki/Visual_Basic_.NET Visual Basic .NET]; parametric polymorphism in [http://en.wikipedia.org/wiki/ML_(programming_language) ML], [http://en.wikipedia.org/wiki/Scala_(programming_language Scala] and [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/template_(programming) template]s in [http://en.wikipedia.org/wiki/C++ C++].&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;For example, given various data structures and several algorithms, the brute force way would be implement them for each data structure which would mean that various combinations of implementations will be necessary. Generic programming reduces this effort.&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Generics in Java==&lt;br /&gt;
===What are Generics?===&lt;br /&gt;
Generics were added to Java programming language as a part of J2SE 5.0 release in 2004. They allow programmers to develop generic and compile safe applications which enables a type or method to operate on objects of various type. This feature is well utilized while implementing [http://en.wikipedia.org/wiki/Java_Collections Java Collections]. The reason why people went into generic programming can be well explained using the below example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  List list = new ArrayList();&lt;br /&gt;
  list.add(&amp;quot;name&amp;quot;);&lt;br /&gt;
  Integer num = (Integer)list.get(0);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In this example, we insert a &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt; into an &amp;lt;code&amp;gt;ArrayList&amp;lt;/code&amp;gt; and retrieve element by typecasting with Integer wrapper class. This throws a runtime exception because of Illegal class cast. But if we use generics, runtime exceptions can be avoided and the compiler will be able to catch such issues which in turn help a programmer to build a bug free code. So if we convert the above code to use generic then it would look like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  List&amp;lt;String&amp;gt; list = new ArrayList&amp;lt;String&amp;gt;();&lt;br /&gt;
  list.add(&amp;quot;name&amp;quot;);&lt;br /&gt;
  Integer num = list.get(0); //line 1 &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here at line 1 the compiler throws an error because the compiler on seeing the declaration of ArrayList will be expecting the list to have just &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt; and thereby the return type of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; to be &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Implementing Generics:===&lt;br /&gt;
Java provides a feature which helps one to implement your own generic types and this will help to build more sophisticated and runtime error free applications. Consider the below example:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
   interface List&amp;lt;N&amp;gt; {&lt;br /&gt;
                         void add(N i);&lt;br /&gt;
                         Iterator&amp;lt;N&amp;gt; iterator();&lt;br /&gt;
                      }&lt;br /&gt;
   interface Iterator&amp;lt;N&amp;gt; {&lt;br /&gt;
                            N next();&lt;br /&gt;
                            boolean hasNext();&lt;br /&gt;
                         }&lt;br /&gt;
   class LinkedList&amp;lt;N&amp;gt; implements List&amp;lt;N&amp;gt; {&lt;br /&gt;
                          //Business Logic   &lt;br /&gt;
                 }&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
So here, &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt; can be replaced with any primitive data types or wrapper classes in the business logic. But we need to make sure that placeholders to be replaced with valid subtypes of Object. Generics implementation is not restricted for classes or interfaces, we can have for static/non static methods and constructors.&lt;br /&gt;
&lt;br /&gt;
Example for generic methods:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;T&amp;gt; void fromArrayToCollection(T[] a, Collection&amp;lt;T&amp;gt; c) {&lt;br /&gt;
    for (T o : a) {&lt;br /&gt;
        c.add(o); // Correct&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Pros and Cons===&lt;br /&gt;
&amp;lt;b&amp;gt;Pros:&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Reduces the number of casts in the program, which in turn reduces the number of potential bugs in the program.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Improves code clarity and maintenance.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;Cons:&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Parameter type information is not available at run time.&amp;lt;/li&amp;gt; &lt;br /&gt;
&amp;lt;li&amp;gt;The automatically generated casts may fail when interoperating with ill-behaved legacy code.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Templates in C++==&lt;br /&gt;
===What are templates?===&lt;br /&gt;
&amp;lt;p&amp;gt;Templates are functions that can operate with &amp;lt;i&amp;gt;generic types&amp;lt;/i&amp;gt; which means that the functionality can be adapted for more than one type of data without repeating the entire code for each type. &lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
===Overview===&lt;br /&gt;
Templates can be either function templates or class templates.&lt;br /&gt;
====Function Templates====&lt;br /&gt;
These are just like regular functions except that they can have arguments of different types. A single function definition works with different kinds of data types. During compile time, the actual functions are generated once the compiler knows the data type being used. This kind of template does not save any memory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Example&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
template &amp;lt;typename Type&amp;gt;&lt;br /&gt;
Type max(Type a, Type b) {&lt;br /&gt;
    return a &amp;gt; b ? a : b;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
  // This will call max &amp;lt;int&amp;gt; (by argument deduction)&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; max(3, 7) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  // This will call max&amp;lt;double&amp;gt; (by argument deduction)&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; max(3.0, 7.0) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  // This type is ambiguous, so explicitly instantiate max&amp;lt;double&amp;gt;&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; max&amp;lt;double&amp;gt;(3, 7.0) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Class Templates====&lt;br /&gt;
A class template provides a specification for generating classes based on parameters. A class template is instantiated by passing a given set of types to it as template arguments.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Example&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
template &amp;lt;class T&amp;gt;&lt;br /&gt;
class mypair {&lt;br /&gt;
    T values [2];&lt;br /&gt;
  public:&lt;br /&gt;
    mypair (T first, T second)&lt;br /&gt;
    {&lt;br /&gt;
      values[0]=first; values[1]=second;&lt;br /&gt;
    }&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Features of C++ Templates===&lt;br /&gt;
Some of the features of C++ templates are:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Implemented in the compiler.&amp;lt;ol&amp;gt;&amp;lt;ul&amp;gt;No runtime overhead&amp;lt;/ul&amp;gt;&amp;lt;ul&amp;gt;Requires template source to be in headers&amp;lt;/ul&amp;gt;&amp;lt;ul&amp;gt;Latent typing means template instantiator does no type checking&amp;lt;/ul&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Gloriﬁed macro facility&amp;lt;ol&amp;gt;&amp;lt;ul&amp;gt;“Macros done right”/“Macros that look like classes”&amp;lt;/ul&amp;gt;&amp;lt;/ol&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Can use template arguments for both classes and straight function&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Template specialization&amp;lt;ol&amp;gt;&amp;lt;ul&amp;gt;Speciﬁc implementation of a templated type or method&amp;lt;/ul&amp;gt;&amp;lt;/ol&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Pattern matching and text replacement&amp;lt;ol&amp;gt;&amp;lt;ul&amp;gt;Declarative model (like [http://en.wikipedia.org/wiki/Prolog Prolog])&amp;lt;/ul&amp;gt;&amp;lt;/ol&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Pros and Cons===&lt;br /&gt;
Usage of templates have both advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Pros&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Reduction in code size.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;They are type-safe, that is, type-checking is done at compile time.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Cons&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Since all compilers are not good at their support for templates, they may not be very portable.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Compilers generate additional code for each template type, this could lead to huge code if usage of templates is not checked.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Information hiding is not achieved as the code is all exposed in the header.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;http://en.wikipedia.org/wiki/Generic_programming&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://en.wikipedia.org/wiki/Generics_in_Java&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://www.oracle.com/technetwork/articles/javase/generics-136597.html&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://download.oracle.com/javase/tutorial/extra/generics/methods.html&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://www.cplusplus.com/doc/tutorial/templates/&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://en.wikipedia.org/wiki/Template_(programming)&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://www.cs.binghamton.edu/~mike/presentations/java-generics-cs580c-fall-2007.pdf&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://jnb.ociweb.com/jnb/jnbJul2003.html&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jnvarava</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6c_sj&amp;diff=55483</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6c sj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6c_sj&amp;diff=55483"/>
		<updated>2011-11-17T14:51:22Z</updated>

		<summary type="html">&lt;p&gt;Jnvarava: /* Pros and Cons */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Generic Programming==&lt;br /&gt;
&amp;lt;p&amp;gt;Generic programming is a style of computer programming in which algorithms are written in terms of &amp;lt;i&amp;gt;to-be-specified-later&amp;lt;/i&amp;gt; types that are then instantiated when needed for specific types provided as parameters. This enables writing common set of functions which differ only in the types on which they operate. This reduces duplication. Software entities created using generic programming are known as ''generics'' in [http://en.wikipedia.org/wiki/Ada_(programming_language) Ada], [http://en.wikipedia.org/wiki/Eiffel_(programming_language) Eiffel], [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/F_Sharp_(programming_language) F#], and [http://en.wikipedia.org/wiki/Visual_Basic_.NET Visual Basic .NET]; parametric polymorphism in [http://en.wikipedia.org/wiki/ML_(programming_language) ML], [http://en.wikipedia.org/wiki/Scala_(programming_language Scala] and [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/template_(programming) template]s in [http://en.wikipedia.org/wiki/C++ C++].&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;For example, given various data structures and several algorithms, the brute force way would be implement them for each data structure which would mean that various combinations of implementations will be necessary. Generic programming reduces this effort.&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Generics in Java==&lt;br /&gt;
===What are Generics?===&lt;br /&gt;
Generics were added to Java programming language as a part of J2SE 5.0 release in 2004. They allow programmers to develop generic and compile safe applications which enables a type or method to operate on objects of various type. This feature is well utilized while implementing [http://en.wikipedia.org/wiki/Java_Collections Java Collections]. The reason why people went into generic programming can be well explained using the below example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  List list = new ArrayList();&lt;br /&gt;
  list.add(&amp;quot;name&amp;quot;);&lt;br /&gt;
  Integer num = (Integer)list.get(0);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In this example, we insert a &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt; into an &amp;lt;code&amp;gt;ArrayList&amp;lt;/code&amp;gt; and retrieve element by typecasting with Integer wrapper class. This throws a runtime exception because of Illegal class cast. But if we use generics, runtime exceptions can be avoided and the compiler will be able to catch such issues which in turn help a programmer to build a bug free code. So if we convert the above code to use generic then it would look like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  List&amp;lt;String&amp;gt; list = new ArrayList&amp;lt;String&amp;gt;();&lt;br /&gt;
  list.add(&amp;quot;name&amp;quot;);&lt;br /&gt;
  Integer num = list.get(0); //line 1 &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here at line 1 the compiler throws an error because the compiler on seeing the declaration of ArrayList will be expecting the list to have just &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt; and thereby the return type of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; to be &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Implementing Generics:===&lt;br /&gt;
Java provides a feature which helps one to implement your own generic types and this will help to build more sophisticated and runtime error free applications. Consider the below example:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
   interface List&amp;lt;N&amp;gt; {&lt;br /&gt;
                         void add(N i);&lt;br /&gt;
                         Iterator&amp;lt;N&amp;gt; iterator();&lt;br /&gt;
                      }&lt;br /&gt;
   interface Iterator&amp;lt;N&amp;gt; {&lt;br /&gt;
                            N next();&lt;br /&gt;
                            boolean hasNext();&lt;br /&gt;
                         }&lt;br /&gt;
   class LinkedList&amp;lt;N&amp;gt; implements List&amp;lt;N&amp;gt; {&lt;br /&gt;
                          //Business Logic   &lt;br /&gt;
                 }&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
So here, &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt; can be replaced with any primitive data types or wrapper classes in the business logic. But we need to make sure that placeholders to be replaced with valid subtypes of Object. Generics implementation is not restricted for classes or interfaces, we can have for static/non static methods and constructors.&lt;br /&gt;
&lt;br /&gt;
Example for generic methods:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;T&amp;gt; void fromArrayToCollection(T[] a, Collection&amp;lt;T&amp;gt; c) {&lt;br /&gt;
    for (T o : a) {&lt;br /&gt;
        c.add(o); // Correct&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Pros and Cons===&lt;br /&gt;
Pros:&lt;br /&gt;
&lt;br /&gt;
1. Reduces the number of casts in the program, which in turn reduces the number of potential bugs in the program.&lt;br /&gt;
&lt;br /&gt;
2. Improves code clarity and maintenance.&lt;br /&gt;
&lt;br /&gt;
==Templates in C++==&lt;br /&gt;
===What are templates?===&lt;br /&gt;
&amp;lt;p&amp;gt;Templates are functions that can operate with &amp;lt;i&amp;gt;generic types&amp;lt;/i&amp;gt; which means that the functionality can be adapted for more than one type of data without repeating the entire code for each type. &lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
===Overview===&lt;br /&gt;
Templates can be either function templates or class templates.&lt;br /&gt;
====Function Templates====&lt;br /&gt;
These are just like regular functions except that they can have arguments of different types. A single function definition works with different kinds of data types. During compile time, the actual functions are generated once the compiler knows the data type being used. This kind of template does not save any memory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Example&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
template &amp;lt;typename Type&amp;gt;&lt;br /&gt;
Type max(Type a, Type b) {&lt;br /&gt;
    return a &amp;gt; b ? a : b;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
  // This will call max &amp;lt;int&amp;gt; (by argument deduction)&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; max(3, 7) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  // This will call max&amp;lt;double&amp;gt; (by argument deduction)&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; max(3.0, 7.0) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  // This type is ambiguous, so explicitly instantiate max&amp;lt;double&amp;gt;&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; max&amp;lt;double&amp;gt;(3, 7.0) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Class Templates====&lt;br /&gt;
A class template provides a specification for generating classes based on parameters. A class template is instantiated by passing a given set of types to it as template arguments.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Example&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
template &amp;lt;class T&amp;gt;&lt;br /&gt;
class mypair {&lt;br /&gt;
    T values [2];&lt;br /&gt;
  public:&lt;br /&gt;
    mypair (T first, T second)&lt;br /&gt;
    {&lt;br /&gt;
      values[0]=first; values[1]=second;&lt;br /&gt;
    }&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Features of C++ Templates===&lt;br /&gt;
Some of the features of C++ templates are:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Implemented in the compiler.&amp;lt;ol&amp;gt;&amp;lt;ul&amp;gt;No runtime overhead&amp;lt;/ul&amp;gt;&amp;lt;ul&amp;gt;Requires template source to be in headers&amp;lt;/ul&amp;gt;&amp;lt;ul&amp;gt;Latent typing means template instantiator does no type checking&amp;lt;/ul&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Gloriﬁed macro facility&amp;lt;ol&amp;gt;&amp;lt;ul&amp;gt;“Macros done right”/“Macros that look like classes”&amp;lt;/ul&amp;gt;&amp;lt;/ol&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Can use template arguments for both classes and straight function&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Template specialization&amp;lt;ol&amp;gt;&amp;lt;ul&amp;gt;Speciﬁc implementation of a templated type or method&amp;lt;/ul&amp;gt;&amp;lt;/ol&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Pattern matching and text replacement&amp;lt;ol&amp;gt;&amp;lt;ul&amp;gt;Declarative model (like [http://en.wikipedia.org/wiki/Prolog Prolog])&amp;lt;/ul&amp;gt;&amp;lt;/ol&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Pros and Cons===&lt;br /&gt;
Usage of templates have both advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Pros&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Reduction in code size.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;They are type-safe, that is, type-checking is done at compile time.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Cons&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Since all compilers are not good at their support for templates, they may not be very portable.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Compilers generate additional code for each template type, this could lead to huge code if usage of templates is not checked.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Information hiding is not achieved as the code is all exposed in the header.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;http://en.wikipedia.org/wiki/Generic_programming&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://en.wikipedia.org/wiki/Generics_in_Java&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://www.oracle.com/technetwork/articles/javase/generics-136597.html&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://download.oracle.com/javase/tutorial/extra/generics/methods.html&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://www.cplusplus.com/doc/tutorial/templates/&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://en.wikipedia.org/wiki/Template_(programming)&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://www.cs.binghamton.edu/~mike/presentations/java-generics-cs580c-fall-2007.pdf&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://jnb.ociweb.com/jnb/jnbJul2003.html&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jnvarava</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6c_sj&amp;diff=55482</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6c sj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6c_sj&amp;diff=55482"/>
		<updated>2011-11-17T14:50:47Z</updated>

		<summary type="html">&lt;p&gt;Jnvarava: /* Reference */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Generic Programming==&lt;br /&gt;
&amp;lt;p&amp;gt;Generic programming is a style of computer programming in which algorithms are written in terms of &amp;lt;i&amp;gt;to-be-specified-later&amp;lt;/i&amp;gt; types that are then instantiated when needed for specific types provided as parameters. This enables writing common set of functions which differ only in the types on which they operate. This reduces duplication. Software entities created using generic programming are known as ''generics'' in [http://en.wikipedia.org/wiki/Ada_(programming_language) Ada], [http://en.wikipedia.org/wiki/Eiffel_(programming_language) Eiffel], [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/F_Sharp_(programming_language) F#], and [http://en.wikipedia.org/wiki/Visual_Basic_.NET Visual Basic .NET]; parametric polymorphism in [http://en.wikipedia.org/wiki/ML_(programming_language) ML], [http://en.wikipedia.org/wiki/Scala_(programming_language Scala] and [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/template_(programming) template]s in [http://en.wikipedia.org/wiki/C++ C++].&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;For example, given various data structures and several algorithms, the brute force way would be implement them for each data structure which would mean that various combinations of implementations will be necessary. Generic programming reduces this effort.&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Generics in Java==&lt;br /&gt;
===What are Generics?===&lt;br /&gt;
Generics were added to Java programming language as a part of J2SE 5.0 release in 2004. They allow programmers to develop generic and compile safe applications which enables a type or method to operate on objects of various type. This feature is well utilized while implementing [http://en.wikipedia.org/wiki/Java_Collections Java Collections]. The reason why people went into generic programming can be well explained using the below example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  List list = new ArrayList();&lt;br /&gt;
  list.add(&amp;quot;name&amp;quot;);&lt;br /&gt;
  Integer num = (Integer)list.get(0);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In this example, we insert a &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt; into an &amp;lt;code&amp;gt;ArrayList&amp;lt;/code&amp;gt; and retrieve element by typecasting with Integer wrapper class. This throws a runtime exception because of Illegal class cast. But if we use generics, runtime exceptions can be avoided and the compiler will be able to catch such issues which in turn help a programmer to build a bug free code. So if we convert the above code to use generic then it would look like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  List&amp;lt;String&amp;gt; list = new ArrayList&amp;lt;String&amp;gt;();&lt;br /&gt;
  list.add(&amp;quot;name&amp;quot;);&lt;br /&gt;
  Integer num = list.get(0); //line 1 &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here at line 1 the compiler throws an error because the compiler on seeing the declaration of ArrayList will be expecting the list to have just &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt; and thereby the return type of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; to be &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Implementing Generics:===&lt;br /&gt;
Java provides a feature which helps one to implement your own generic types and this will help to build more sophisticated and runtime error free applications. Consider the below example:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
   interface List&amp;lt;N&amp;gt; {&lt;br /&gt;
                         void add(N i);&lt;br /&gt;
                         Iterator&amp;lt;N&amp;gt; iterator();&lt;br /&gt;
                      }&lt;br /&gt;
   interface Iterator&amp;lt;N&amp;gt; {&lt;br /&gt;
                            N next();&lt;br /&gt;
                            boolean hasNext();&lt;br /&gt;
                         }&lt;br /&gt;
   class LinkedList&amp;lt;N&amp;gt; implements List&amp;lt;N&amp;gt; {&lt;br /&gt;
                          //Business Logic   &lt;br /&gt;
                 }&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
So here, &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt; can be replaced with any primitive data types or wrapper classes in the business logic. But we need to make sure that placeholders to be replaced with valid subtypes of Object. Generics implementation is not restricted for classes or interfaces, we can have for static/non static methods and constructors.&lt;br /&gt;
&lt;br /&gt;
Example for generic methods:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;T&amp;gt; void fromArrayToCollection(T[] a, Collection&amp;lt;T&amp;gt; c) {&lt;br /&gt;
    for (T o : a) {&lt;br /&gt;
        c.add(o); // Correct&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Pros and Cons===&lt;br /&gt;
The two major benefits of generics in Java are:&lt;br /&gt;
&lt;br /&gt;
1. Reduces the number of casts in the program, which in turn reduces the number of potential bugs in the program.&lt;br /&gt;
2. Improves code clarity and maintenance.&lt;br /&gt;
&lt;br /&gt;
==Templates in C++==&lt;br /&gt;
===What are templates?===&lt;br /&gt;
&amp;lt;p&amp;gt;Templates are functions that can operate with &amp;lt;i&amp;gt;generic types&amp;lt;/i&amp;gt; which means that the functionality can be adapted for more than one type of data without repeating the entire code for each type. &lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
===Overview===&lt;br /&gt;
Templates can be either function templates or class templates.&lt;br /&gt;
====Function Templates====&lt;br /&gt;
These are just like regular functions except that they can have arguments of different types. A single function definition works with different kinds of data types. During compile time, the actual functions are generated once the compiler knows the data type being used. This kind of template does not save any memory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Example&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
template &amp;lt;typename Type&amp;gt;&lt;br /&gt;
Type max(Type a, Type b) {&lt;br /&gt;
    return a &amp;gt; b ? a : b;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
  // This will call max &amp;lt;int&amp;gt; (by argument deduction)&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; max(3, 7) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  // This will call max&amp;lt;double&amp;gt; (by argument deduction)&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; max(3.0, 7.0) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  // This type is ambiguous, so explicitly instantiate max&amp;lt;double&amp;gt;&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; max&amp;lt;double&amp;gt;(3, 7.0) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Class Templates====&lt;br /&gt;
A class template provides a specification for generating classes based on parameters. A class template is instantiated by passing a given set of types to it as template arguments.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Example&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
template &amp;lt;class T&amp;gt;&lt;br /&gt;
class mypair {&lt;br /&gt;
    T values [2];&lt;br /&gt;
  public:&lt;br /&gt;
    mypair (T first, T second)&lt;br /&gt;
    {&lt;br /&gt;
      values[0]=first; values[1]=second;&lt;br /&gt;
    }&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Features of C++ Templates===&lt;br /&gt;
Some of the features of C++ templates are:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Implemented in the compiler.&amp;lt;ol&amp;gt;&amp;lt;ul&amp;gt;No runtime overhead&amp;lt;/ul&amp;gt;&amp;lt;ul&amp;gt;Requires template source to be in headers&amp;lt;/ul&amp;gt;&amp;lt;ul&amp;gt;Latent typing means template instantiator does no type checking&amp;lt;/ul&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Gloriﬁed macro facility&amp;lt;ol&amp;gt;&amp;lt;ul&amp;gt;“Macros done right”/“Macros that look like classes”&amp;lt;/ul&amp;gt;&amp;lt;/ol&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Can use template arguments for both classes and straight function&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Template specialization&amp;lt;ol&amp;gt;&amp;lt;ul&amp;gt;Speciﬁc implementation of a templated type or method&amp;lt;/ul&amp;gt;&amp;lt;/ol&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Pattern matching and text replacement&amp;lt;ol&amp;gt;&amp;lt;ul&amp;gt;Declarative model (like [http://en.wikipedia.org/wiki/Prolog Prolog])&amp;lt;/ul&amp;gt;&amp;lt;/ol&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Pros and Cons===&lt;br /&gt;
Usage of templates have both advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Pros&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Reduction in code size.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;They are type-safe, that is, type-checking is done at compile time.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Cons&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Since all compilers are not good at their support for templates, they may not be very portable.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Compilers generate additional code for each template type, this could lead to huge code if usage of templates is not checked.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Information hiding is not achieved as the code is all exposed in the header.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;http://en.wikipedia.org/wiki/Generic_programming&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://en.wikipedia.org/wiki/Generics_in_Java&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://www.oracle.com/technetwork/articles/javase/generics-136597.html&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://download.oracle.com/javase/tutorial/extra/generics/methods.html&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://www.cplusplus.com/doc/tutorial/templates/&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://en.wikipedia.org/wiki/Template_(programming)&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://www.cs.binghamton.edu/~mike/presentations/java-generics-cs580c-fall-2007.pdf&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://jnb.ociweb.com/jnb/jnbJul2003.html&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jnvarava</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6c_sj&amp;diff=55481</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6c sj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6c_sj&amp;diff=55481"/>
		<updated>2011-11-17T14:50:08Z</updated>

		<summary type="html">&lt;p&gt;Jnvarava: /* Generics in Java */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Generic Programming==&lt;br /&gt;
&amp;lt;p&amp;gt;Generic programming is a style of computer programming in which algorithms are written in terms of &amp;lt;i&amp;gt;to-be-specified-later&amp;lt;/i&amp;gt; types that are then instantiated when needed for specific types provided as parameters. This enables writing common set of functions which differ only in the types on which they operate. This reduces duplication. Software entities created using generic programming are known as ''generics'' in [http://en.wikipedia.org/wiki/Ada_(programming_language) Ada], [http://en.wikipedia.org/wiki/Eiffel_(programming_language) Eiffel], [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/F_Sharp_(programming_language) F#], and [http://en.wikipedia.org/wiki/Visual_Basic_.NET Visual Basic .NET]; parametric polymorphism in [http://en.wikipedia.org/wiki/ML_(programming_language) ML], [http://en.wikipedia.org/wiki/Scala_(programming_language Scala] and [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/template_(programming) template]s in [http://en.wikipedia.org/wiki/C++ C++].&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;For example, given various data structures and several algorithms, the brute force way would be implement them for each data structure which would mean that various combinations of implementations will be necessary. Generic programming reduces this effort.&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Generics in Java==&lt;br /&gt;
===What are Generics?===&lt;br /&gt;
Generics were added to Java programming language as a part of J2SE 5.0 release in 2004. They allow programmers to develop generic and compile safe applications which enables a type or method to operate on objects of various type. This feature is well utilized while implementing [http://en.wikipedia.org/wiki/Java_Collections Java Collections]. The reason why people went into generic programming can be well explained using the below example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  List list = new ArrayList();&lt;br /&gt;
  list.add(&amp;quot;name&amp;quot;);&lt;br /&gt;
  Integer num = (Integer)list.get(0);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In this example, we insert a &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt; into an &amp;lt;code&amp;gt;ArrayList&amp;lt;/code&amp;gt; and retrieve element by typecasting with Integer wrapper class. This throws a runtime exception because of Illegal class cast. But if we use generics, runtime exceptions can be avoided and the compiler will be able to catch such issues which in turn help a programmer to build a bug free code. So if we convert the above code to use generic then it would look like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  List&amp;lt;String&amp;gt; list = new ArrayList&amp;lt;String&amp;gt;();&lt;br /&gt;
  list.add(&amp;quot;name&amp;quot;);&lt;br /&gt;
  Integer num = list.get(0); //line 1 &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here at line 1 the compiler throws an error because the compiler on seeing the declaration of ArrayList will be expecting the list to have just &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt; and thereby the return type of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; to be &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Implementing Generics:===&lt;br /&gt;
Java provides a feature which helps one to implement your own generic types and this will help to build more sophisticated and runtime error free applications. Consider the below example:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
   interface List&amp;lt;N&amp;gt; {&lt;br /&gt;
                         void add(N i);&lt;br /&gt;
                         Iterator&amp;lt;N&amp;gt; iterator();&lt;br /&gt;
                      }&lt;br /&gt;
   interface Iterator&amp;lt;N&amp;gt; {&lt;br /&gt;
                            N next();&lt;br /&gt;
                            boolean hasNext();&lt;br /&gt;
                         }&lt;br /&gt;
   class LinkedList&amp;lt;N&amp;gt; implements List&amp;lt;N&amp;gt; {&lt;br /&gt;
                          //Business Logic   &lt;br /&gt;
                 }&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
So here, &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt; can be replaced with any primitive data types or wrapper classes in the business logic. But we need to make sure that placeholders to be replaced with valid subtypes of Object. Generics implementation is not restricted for classes or interfaces, we can have for static/non static methods and constructors.&lt;br /&gt;
&lt;br /&gt;
Example for generic methods:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;T&amp;gt; void fromArrayToCollection(T[] a, Collection&amp;lt;T&amp;gt; c) {&lt;br /&gt;
    for (T o : a) {&lt;br /&gt;
        c.add(o); // Correct&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Pros and Cons===&lt;br /&gt;
The two major benefits of generics in Java are:&lt;br /&gt;
&lt;br /&gt;
1. Reduces the number of casts in the program, which in turn reduces the number of potential bugs in the program.&lt;br /&gt;
2. Improves code clarity and maintenance.&lt;br /&gt;
&lt;br /&gt;
==Templates in C++==&lt;br /&gt;
===What are templates?===&lt;br /&gt;
&amp;lt;p&amp;gt;Templates are functions that can operate with &amp;lt;i&amp;gt;generic types&amp;lt;/i&amp;gt; which means that the functionality can be adapted for more than one type of data without repeating the entire code for each type. &lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
===Overview===&lt;br /&gt;
Templates can be either function templates or class templates.&lt;br /&gt;
====Function Templates====&lt;br /&gt;
These are just like regular functions except that they can have arguments of different types. A single function definition works with different kinds of data types. During compile time, the actual functions are generated once the compiler knows the data type being used. This kind of template does not save any memory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Example&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
template &amp;lt;typename Type&amp;gt;&lt;br /&gt;
Type max(Type a, Type b) {&lt;br /&gt;
    return a &amp;gt; b ? a : b;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
  // This will call max &amp;lt;int&amp;gt; (by argument deduction)&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; max(3, 7) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  // This will call max&amp;lt;double&amp;gt; (by argument deduction)&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; max(3.0, 7.0) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  // This type is ambiguous, so explicitly instantiate max&amp;lt;double&amp;gt;&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; max&amp;lt;double&amp;gt;(3, 7.0) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Class Templates====&lt;br /&gt;
A class template provides a specification for generating classes based on parameters. A class template is instantiated by passing a given set of types to it as template arguments.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Example&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
template &amp;lt;class T&amp;gt;&lt;br /&gt;
class mypair {&lt;br /&gt;
    T values [2];&lt;br /&gt;
  public:&lt;br /&gt;
    mypair (T first, T second)&lt;br /&gt;
    {&lt;br /&gt;
      values[0]=first; values[1]=second;&lt;br /&gt;
    }&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Features of C++ Templates===&lt;br /&gt;
Some of the features of C++ templates are:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Implemented in the compiler.&amp;lt;ol&amp;gt;&amp;lt;ul&amp;gt;No runtime overhead&amp;lt;/ul&amp;gt;&amp;lt;ul&amp;gt;Requires template source to be in headers&amp;lt;/ul&amp;gt;&amp;lt;ul&amp;gt;Latent typing means template instantiator does no type checking&amp;lt;/ul&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Gloriﬁed macro facility&amp;lt;ol&amp;gt;&amp;lt;ul&amp;gt;“Macros done right”/“Macros that look like classes”&amp;lt;/ul&amp;gt;&amp;lt;/ol&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Can use template arguments for both classes and straight function&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Template specialization&amp;lt;ol&amp;gt;&amp;lt;ul&amp;gt;Speciﬁc implementation of a templated type or method&amp;lt;/ul&amp;gt;&amp;lt;/ol&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Pattern matching and text replacement&amp;lt;ol&amp;gt;&amp;lt;ul&amp;gt;Declarative model (like [http://en.wikipedia.org/wiki/Prolog Prolog])&amp;lt;/ul&amp;gt;&amp;lt;/ol&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Pros and Cons===&lt;br /&gt;
Usage of templates have both advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Pros&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Reduction in code size.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;They are type-safe, that is, type-checking is done at compile time.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Cons&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Since all compilers are not good at their support for templates, they may not be very portable.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Compilers generate additional code for each template type, this could lead to huge code if usage of templates is not checked.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Information hiding is not achieved as the code is all exposed in the header.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;http://en.wikipedia.org/wiki/Generic_programming&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://en.wikipedia.org/wiki/Generics_in_Java&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://www.oracle.com/technetwork/articles/javase/generics-136597.html&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://download.oracle.com/javase/tutorial/extra/generics/methods.html&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://www.cplusplus.com/doc/tutorial/templates/&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://en.wikipedia.org/wiki/Template_(programming)&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://www.cs.binghamton.edu/~mike/presentations/java-generics-cs580c-fall-2007.pdf&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jnvarava</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6c_sj&amp;diff=55479</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6c sj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6c_sj&amp;diff=55479"/>
		<updated>2011-11-17T14:33:22Z</updated>

		<summary type="html">&lt;p&gt;Jnvarava: /* Generics in Java? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Generic Programming==&lt;br /&gt;
&amp;lt;p&amp;gt;Generic programming is a style of computer programming in which algorithms are written in terms of &amp;lt;i&amp;gt;to-be-specified-later&amp;lt;/i&amp;gt; types that are then instantiated when needed for specific types provided as parameters. This enables writing common set of functions which differ only in the types on which they operate. This reduces duplication. Software entities created using generic programming are known as ''generics'' in [http://en.wikipedia.org/wiki/Ada_(programming_language) Ada], [http://en.wikipedia.org/wiki/Eiffel_(programming_language) Eiffel], [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/F_Sharp_(programming_language) F#], and [http://en.wikipedia.org/wiki/Visual_Basic_.NET Visual Basic .NET]; parametric polymorphism in [http://en.wikipedia.org/wiki/ML_(programming_language) ML], [http://en.wikipedia.org/wiki/Scala_(programming_language Scala] and [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/template_(programming) template]s in [http://en.wikipedia.org/wiki/C++ C++].&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;For example, given various data structures and several algorithms, the brute force way would be implement them for each data structure which would mean that various combinations of implementations will be necessary. Generic programming reduces this effort.&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Generics in Java==&lt;br /&gt;
===What are Generics?===&lt;br /&gt;
Generics were added to Java programming language as a part of J2SE 5.0 release in 2004. They allow programmers to develop generic and compile safe applications which enables a type or method to operate on objects of various type. This feature is well utilized while implementing [http://en.wikipedia.org/wiki/Java_Collections Java Collections]. The reason why people went into generic programming can be well explained using the below example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  List list = new ArrayList();&lt;br /&gt;
  list.add(&amp;quot;name&amp;quot;);&lt;br /&gt;
  Integer num = (Integer)list.get(0);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In this example, we insert a &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt; into an &amp;lt;code&amp;gt;ArrayList&amp;lt;/code&amp;gt; and retrieve element by typecasting with Integer wrapper class. This throws a runtime exception because of Illegal class cast. But if we use generics, runtime exceptions can be avoided and the compiler will be able to catch such issues which in turn help a programmer to build a bug free code. So if we convert the above code to use generic then it would look like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  List&amp;lt;String&amp;gt; list = new ArrayList&amp;lt;String&amp;gt;();&lt;br /&gt;
  list.add(&amp;quot;name&amp;quot;);&lt;br /&gt;
  Integer num = list.get(0); //line 1 &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here at line 1 the compiler throws an error because the compiler on seeing the declaration of ArrayList will be expecting the list to have just &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt; and thereby the return type of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; to be &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Implementing Generics:===&lt;br /&gt;
Java provides a feature which helps one to implement your own generic types and this will help to build more sophisticated and runtime error free applications. Consider the below example:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
   interface List&amp;lt;N&amp;gt; {&lt;br /&gt;
                         void add(N i);&lt;br /&gt;
                         Iterator&amp;lt;N&amp;gt; iterator();&lt;br /&gt;
                      }&lt;br /&gt;
   interface Iterator&amp;lt;N&amp;gt; {&lt;br /&gt;
                            N next();&lt;br /&gt;
                            boolean hasNext();&lt;br /&gt;
                         }&lt;br /&gt;
   class LinkedList&amp;lt;N&amp;gt; implements List&amp;lt;N&amp;gt; {&lt;br /&gt;
                          //Business Logic   &lt;br /&gt;
                 }&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
So here, &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt; can be replaced with any primitive data types or wrapper classes in the business logic. But we need to make sure that placeholders to be replaced with valid subtypes of Object. Generics implementation is not restricted for classes or interfaces, we can have for static/non static methods and constructors.&lt;br /&gt;
&lt;br /&gt;
Example for generic methods:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;T&amp;gt; void fromArrayToCollection(T[] a, Collection&amp;lt;T&amp;gt; c) {&lt;br /&gt;
    for (T o : a) {&lt;br /&gt;
        c.add(o); // Correct&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Templates in C++==&lt;br /&gt;
===What are templates?===&lt;br /&gt;
&amp;lt;p&amp;gt;Templates are functions that can operate with &amp;lt;i&amp;gt;generic types&amp;lt;/i&amp;gt; which means that the functionality can be adapted for more than one type of data without repeating the entire code for each type. &lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
===Overview===&lt;br /&gt;
Templates can be either function templates or class templates.&lt;br /&gt;
====Function Templates====&lt;br /&gt;
These are just like regular functions except that they can have arguments of different types. A single function definition works with different kinds of data types. During compile time, the actual functions are generated once the compiler knows the data type being used. This kind of template does not save any memory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Example&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
template &amp;lt;typename Type&amp;gt;&lt;br /&gt;
Type max(Type a, Type b) {&lt;br /&gt;
    return a &amp;gt; b ? a : b;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
  // This will call max &amp;lt;int&amp;gt; (by argument deduction)&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; max(3, 7) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  // This will call max&amp;lt;double&amp;gt; (by argument deduction)&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; max(3.0, 7.0) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  // This type is ambiguous, so explicitly instantiate max&amp;lt;double&amp;gt;&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; max&amp;lt;double&amp;gt;(3, 7.0) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Class Templates====&lt;br /&gt;
A class template provides a specification for generating classes based on parameters. A class template is instantiated by passing a given set of types to it as template arguments.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Example&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
template &amp;lt;class T&amp;gt;&lt;br /&gt;
class mypair {&lt;br /&gt;
    T values [2];&lt;br /&gt;
  public:&lt;br /&gt;
    mypair (T first, T second)&lt;br /&gt;
    {&lt;br /&gt;
      values[0]=first; values[1]=second;&lt;br /&gt;
    }&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Features of C++ Templates===&lt;br /&gt;
Some of the features of C++ templates are:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Implemented in the compiler.&amp;lt;ol&amp;gt;&amp;lt;ul&amp;gt;No runtime overhead&amp;lt;/ul&amp;gt;&amp;lt;ul&amp;gt;Requires template source to be in headers&amp;lt;/ul&amp;gt;&amp;lt;ul&amp;gt;Latent typing means template instantiator does no type checking&amp;lt;/ul&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Gloriﬁed macro facility&amp;lt;ol&amp;gt;&amp;lt;ul&amp;gt;“Macros done right”/“Macros that look like classes”&amp;lt;/ul&amp;gt;&amp;lt;/ol&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Can use template arguments for both classes and straight function&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Template specialization&amp;lt;ol&amp;gt;&amp;lt;ul&amp;gt;Speciﬁc implementation of a templated type or method&amp;lt;/ul&amp;gt;&amp;lt;/ol&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Pattern matching and text replacement&amp;lt;ol&amp;gt;&amp;lt;ul&amp;gt;Declarative model (like [http://en.wikipedia.org/wiki/Prolog Prolog])&amp;lt;/ul&amp;gt;&amp;lt;/ol&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Pros and Cons===&lt;br /&gt;
Usage of templates have both advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Pros&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Reduction in code size.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;They are type-safe, that is, type-checking is done at compile time.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Cons&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Since all compilers are not good at their support for templates, they may not be very portable.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Compilers generate additional code for each template type, this could lead to huge code if usage of templates is not checked.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Information hiding is not achieved as the code is all exposed in the header.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;http://en.wikipedia.org/wiki/Generic_programming&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://en.wikipedia.org/wiki/Generics_in_Java&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://www.oracle.com/technetwork/articles/javase/generics-136597.html&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://download.oracle.com/javase/tutorial/extra/generics/methods.html&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://www.cplusplus.com/doc/tutorial/templates/&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://en.wikipedia.org/wiki/Template_(programming)&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://www.cs.binghamton.edu/~mike/presentations/java-generics-cs580c-fall-2007.pdf&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jnvarava</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6c_sj&amp;diff=55477</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6c sj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6c_sj&amp;diff=55477"/>
		<updated>2011-11-17T14:29:01Z</updated>

		<summary type="html">&lt;p&gt;Jnvarava: /* Generics in Java? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Generic Programming==&lt;br /&gt;
&amp;lt;p&amp;gt;Generic programming is a style of computer programming in which algorithms are written in terms of &amp;lt;i&amp;gt;to-be-specified-later&amp;lt;/i&amp;gt; types that are then instantiated when needed for specific types provided as parameters. This enables writing common set of functions which differ only in the types on which they operate. This reduces duplication. Software entities created using generic programming are known as ''generics'' in [http://en.wikipedia.org/wiki/Ada_(programming_language) Ada], [http://en.wikipedia.org/wiki/Eiffel_(programming_language) Eiffel], [http://en.wikipedia.org/wiki/Java_(programming_language) Java], [http://en.wikipedia.org/wiki/C_Sharp_(programming_language) C#], [http://en.wikipedia.org/wiki/F_Sharp_(programming_language) F#], and [http://en.wikipedia.org/wiki/Visual_Basic_.NET Visual Basic .NET]; parametric polymorphism in [http://en.wikipedia.org/wiki/ML_(programming_language) ML], [http://en.wikipedia.org/wiki/Scala_(programming_language Scala] and [http://en.wikipedia.org/wiki/Haskell_(programming_language) Haskell], [http://en.wikipedia.org/wiki/template_(programming) template]s in [http://en.wikipedia.org/wiki/C++ C++].&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;For example, given various data structures and several algorithms, the brute force way would be implement them for each data structure which would mean that various combinations of implementations will be necessary. Generic programming reduces this effort.&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Generics in Java?==&lt;br /&gt;
Generics were added to Java programming language as a part of J2SE 5.0 release in 2004. They allow programmers to develop generic and compile safe applications which enables a type or method to operate on objects of various type. This feature is well utilized while implementing [http://en.wikipedia.org/wiki/Java_Collections Java Collections]. The reason why people went into generic programming can be well explained using the below example:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  List list = new ArrayList();&lt;br /&gt;
  list.add(&amp;quot;name&amp;quot;);&lt;br /&gt;
  Integer num = (Integer)list.get(0);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
In this example, we insert a &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt; into an &amp;lt;code&amp;gt;ArrayList&amp;lt;/code&amp;gt; and retrieve element by typecasting with Integer wrapper class. This throws a runtime exception because of Illegal class cast. But if we use generics, runtime exceptions can be avoided and the compiler will be able to catch such issues which in turn help a programmer to build a bug free code. So if we convert the above code to use generic then it would look like this:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  List&amp;lt;String&amp;gt; list = new ArrayList&amp;lt;String&amp;gt;();&lt;br /&gt;
  list.add(&amp;quot;name&amp;quot;);&lt;br /&gt;
  Integer num = list.get(0); //line 1 &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Here at line 1 the compiler throws an error because the compiler on seeing the declaration of ArrayList will be expecting the list to have just &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt; and thereby the return type of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; to be &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Implementing Generics:'''&lt;br /&gt;
Java provides a feature which helps one to implement your own generic types and this will help to build more sophisticated and runtime error free applications. Consider the below example:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
   interface List&amp;lt;N&amp;gt; {&lt;br /&gt;
                         void add(N i);&lt;br /&gt;
                         Iterator&amp;lt;N&amp;gt; iterator();&lt;br /&gt;
                      }&lt;br /&gt;
   interface Iterator&amp;lt;N&amp;gt; {&lt;br /&gt;
                            N next();&lt;br /&gt;
                            boolean hasNext();&lt;br /&gt;
                         }&lt;br /&gt;
   class LinkedList&amp;lt;N&amp;gt; implements List&amp;lt;N&amp;gt; {&lt;br /&gt;
                          //Business Logic   &lt;br /&gt;
                 }&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
So here, &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt; can be replaced with any primitive data types or wrapper classes in the business logic. But we need to make sure that placeholders to be replaced with valid subtypes of Object. Generics implementation is not restricted for classes or interfaces, we can have for static/non static methods and constructors.&lt;br /&gt;
&lt;br /&gt;
Example for generic methods:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;T&amp;gt; void fromArrayToCollection(T[] a, Collection&amp;lt;T&amp;gt; c) {&lt;br /&gt;
    for (T o : a) {&lt;br /&gt;
        c.add(o); // Correct&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Templates in C++==&lt;br /&gt;
===What are templates?===&lt;br /&gt;
&amp;lt;p&amp;gt;Templates are functions that can operate with &amp;lt;i&amp;gt;generic types&amp;lt;/i&amp;gt; which means that the functionality can be adapted for more than one type of data without repeating the entire code for each type. &lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
===Overview===&lt;br /&gt;
Templates can be either function templates or class templates.&lt;br /&gt;
====Function Templates====&lt;br /&gt;
These are just like regular functions except that they can have arguments of different types. A single function definition works with different kinds of data types. During compile time, the actual functions are generated once the compiler knows the data type being used. This kind of template does not save any memory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Example&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
template &amp;lt;typename Type&amp;gt;&lt;br /&gt;
Type max(Type a, Type b) {&lt;br /&gt;
    return a &amp;gt; b ? a : b;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
  // This will call max &amp;lt;int&amp;gt; (by argument deduction)&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; max(3, 7) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  // This will call max&amp;lt;double&amp;gt; (by argument deduction)&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; max(3.0, 7.0) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  // This type is ambiguous, so explicitly instantiate max&amp;lt;double&amp;gt;&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; max&amp;lt;double&amp;gt;(3, 7.0) &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Class Templates====&lt;br /&gt;
A class template provides a specification for generating classes based on parameters. A class template is instantiated by passing a given set of types to it as template arguments.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Example&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
template &amp;lt;class T&amp;gt;&lt;br /&gt;
class mypair {&lt;br /&gt;
    T values [2];&lt;br /&gt;
  public:&lt;br /&gt;
    mypair (T first, T second)&lt;br /&gt;
    {&lt;br /&gt;
      values[0]=first; values[1]=second;&lt;br /&gt;
    }&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Features of C++ Templates===&lt;br /&gt;
Some of the features of C++ templates are:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Implemented in the compiler.&amp;lt;ol&amp;gt;&amp;lt;ul&amp;gt;No runtime overhead&amp;lt;/ul&amp;gt;&amp;lt;ul&amp;gt;Requires template source to be in headers&amp;lt;/ul&amp;gt;&amp;lt;ul&amp;gt;Latent typing means template instantiator does no type checking&amp;lt;/ul&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Gloriﬁed macro facility&amp;lt;ol&amp;gt;&amp;lt;ul&amp;gt;“Macros done right”/“Macros that look like classes”&amp;lt;/ul&amp;gt;&amp;lt;/ol&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
Can use template arguments for both classes and straight function&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Template specialization&amp;lt;ol&amp;gt;&amp;lt;ul&amp;gt;Speciﬁc implementation of a templated type or method&amp;lt;/ul&amp;gt;&amp;lt;/ol&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Pattern matching and text replacement&amp;lt;ol&amp;gt;&amp;lt;ul&amp;gt;Declarative model (like [http://en.wikipedia.org/wiki/Prolog Prolog])&amp;lt;/ul&amp;gt;&amp;lt;/ol&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Pros and Cons===&lt;br /&gt;
Usage of templates have both advantages and disadvantages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Pros&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Reduction in code size.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;They are type-safe, that is, type-checking is done at compile time.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Cons&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Since all compilers are not good at their support for templates, they may not be very portable.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Compilers generate additional code for each template type, this could lead to huge code if usage of templates is not checked.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Information hiding is not achieved as the code is all exposed in the header.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;http://en.wikipedia.org/wiki/Generic_programming&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://en.wikipedia.org/wiki/Generics_in_Java&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://www.oracle.com/technetwork/articles/javase/generics-136597.html&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://download.oracle.com/javase/tutorial/extra/generics/methods.html&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://www.cplusplus.com/doc/tutorial/templates/&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://en.wikipedia.org/wiki/Template_(programming)&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;http://www.cs.binghamton.edu/~mike/presentations/java-generics-cs580c-fall-2007.pdf&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jnvarava</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6c_sj&amp;diff=54895</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6c sj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6c_sj&amp;diff=54895"/>
		<updated>2011-11-13T22:35:47Z</updated>

		<summary type="html">&lt;p&gt;Jnvarava: /* What are Generics in Java? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==What are Generics in Java?==&lt;br /&gt;
Generics were added to Java programming language as a part of J2SE 5.0 release in 2004. They allow programmers to develop generic and compile safe applications which enables a type or method to operate on objects of various type. This feature is well utilized while implementing [http://en.wikipedia.org/wiki/Java_Collections Java Collections]. The reason why people went into generic programming can be well explained using the below example:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  List list = new ArrayList();&lt;br /&gt;
  list.add(&amp;quot;name&amp;quot;);&lt;br /&gt;
  Integer num = (Integer)list.get(0);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
In this example, we insert a &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt; into an &amp;lt;code&amp;gt;ArrayList&amp;lt;/code&amp;gt; and retrieve element by typecasting with Integer wrapper class. This throws a runtime exception because of Illegal class cast. But if we use generics, runtime exceptions can be avoided and the compiler will be able to catch such issues which in turn help a programmer to build a bug free code. So if we convert the above code to use generic then it would look like this:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  List&amp;lt;String&amp;gt; list = new ArrayList&amp;lt;String&amp;gt;();&lt;br /&gt;
  list.add(&amp;quot;name&amp;quot;);&lt;br /&gt;
  Integer num = list.get(0); //line 1 &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Here at line 1 the compiler throws an error because the compiler on seeing the declaration of ArrayList will be expecting the list to have just &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt; and thereby the return type of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; to be &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Implementing Generics:'''&lt;br /&gt;
Java provides a feature which helps one to implement your own generic types and this will help to build more sophisticated and runtime error free applications. Consider the below example:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
   interface List&amp;lt;N&amp;gt; {&lt;br /&gt;
                         void add(N i);&lt;br /&gt;
                         Iterator&amp;lt;N&amp;gt; iterator();&lt;br /&gt;
                      }&lt;br /&gt;
   interface Iterator&amp;lt;N&amp;gt; {&lt;br /&gt;
                            N next();&lt;br /&gt;
                            boolean hasNext();&lt;br /&gt;
                         }&lt;br /&gt;
   class LinkedList&amp;lt;N&amp;gt; implements List&amp;lt;N&amp;gt; {&lt;br /&gt;
                          //Business Logic   &lt;br /&gt;
                 }&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
So here, &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt; can be replaced with any primitive data types or wrapper classes in the business logic. But we need to make sure that placeholders to be replaced with valid subtypes of Object. Generics implementation is not restricted for classes or interfaces, we can have for static/non static methods and constructors.&lt;br /&gt;
&lt;br /&gt;
Example for generic methods:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
static &amp;lt;T&amp;gt; void fromArrayToCollection(T[] a, Collection&amp;lt;T&amp;gt; c) {&lt;br /&gt;
    for (T o : a) {&lt;br /&gt;
        c.add(o); // Correct&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
1. http://en.wikipedia.org/wiki/Generics_in_Java&lt;br /&gt;
&lt;br /&gt;
2. http://www.oracle.com/technetwork/articles/javase/generics-136597.html&lt;br /&gt;
&lt;br /&gt;
3. http://download.oracle.com/javase/tutorial/extra/generics/methods.html&lt;/div&gt;</summary>
		<author><name>Jnvarava</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6c_sj&amp;diff=54894</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6c sj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6c_sj&amp;diff=54894"/>
		<updated>2011-11-13T22:33:50Z</updated>

		<summary type="html">&lt;p&gt;Jnvarava: /* Reference */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==What are Generics in Java?==&lt;br /&gt;
Generics were added to Java programming language as a part of J2SE 5.0 release in 2004. They allow programmers to develop generic and compile safe applications which enables a type or method to operate on objects of various type. This feature is well utilized while implementing [http://en.wikipedia.org/wiki/Java_Collections Java Collections]. The reason why people went into generic programming can be well explained using the below example:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  List list = new ArrayList();&lt;br /&gt;
  list.add(&amp;quot;name&amp;quot;);&lt;br /&gt;
  Integer num = (Integer)list.get(0);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
In this example, we insert a &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt; into an &amp;lt;code&amp;gt;ArrayList&amp;lt;/code&amp;gt; and retrieve element by typecasting with Integer wrapper class. This throws a runtime exception because of Illegal class cast. But if we use generics, runtime exceptions can be avoided and the compiler will be able to catch such issues which in turn help a programmer to build a bug free code. So if we convert the above code to use generic then it would look like this:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  List&amp;lt;String&amp;gt; list = new ArrayList&amp;lt;String&amp;gt;();&lt;br /&gt;
  list.add(&amp;quot;name&amp;quot;);&lt;br /&gt;
  Integer num = list.get(0); //line 1 &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Here at line 1 the compiler throws an error because the compiler on seeing the declaration of ArrayList will be expecting the list to have just &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt; and thereby the return type of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; to be &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Implementing Generics:'''&lt;br /&gt;
Java provides a feature which helps one to implement your own generic types and this will help to build more sophisticated and runtime error free applications. Consider the below example:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
   interface List&amp;lt;N&amp;gt; {&lt;br /&gt;
                         void add(N i);&lt;br /&gt;
                         Iterator&amp;lt;N&amp;gt; iterator();&lt;br /&gt;
                      }&lt;br /&gt;
   interface Iterator&amp;lt;N&amp;gt; {&lt;br /&gt;
                            N next();&lt;br /&gt;
                            boolean hasNext();&lt;br /&gt;
                         }&lt;br /&gt;
   class LinkedList&amp;lt;N&amp;gt; implements List&amp;lt;N&amp;gt; {&lt;br /&gt;
                          //Business Logic   &lt;br /&gt;
                 }&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
So here, &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt; can be replaced with any primitive data types or wrapper classes in the business logic. But we need to make sure that placeholders to be replaced with valid subtypes of Object. Generics implementation is not restricted for classes or interfaces, we can have for static/non static methods and constructors.&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
1. http://en.wikipedia.org/wiki/Generics_in_Java&lt;br /&gt;
&lt;br /&gt;
2. http://www.oracle.com/technetwork/articles/javase/generics-136597.html&lt;br /&gt;
&lt;br /&gt;
3. http://download.oracle.com/javase/tutorial/extra/generics/methods.html&lt;/div&gt;</summary>
		<author><name>Jnvarava</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6c_sj&amp;diff=54893</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6c sj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6c_sj&amp;diff=54893"/>
		<updated>2011-11-13T22:33:39Z</updated>

		<summary type="html">&lt;p&gt;Jnvarava: /* What are Generics in Java? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==What are Generics in Java?==&lt;br /&gt;
Generics were added to Java programming language as a part of J2SE 5.0 release in 2004. They allow programmers to develop generic and compile safe applications which enables a type or method to operate on objects of various type. This feature is well utilized while implementing [http://en.wikipedia.org/wiki/Java_Collections Java Collections]. The reason why people went into generic programming can be well explained using the below example:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  List list = new ArrayList();&lt;br /&gt;
  list.add(&amp;quot;name&amp;quot;);&lt;br /&gt;
  Integer num = (Integer)list.get(0);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
In this example, we insert a &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt; into an &amp;lt;code&amp;gt;ArrayList&amp;lt;/code&amp;gt; and retrieve element by typecasting with Integer wrapper class. This throws a runtime exception because of Illegal class cast. But if we use generics, runtime exceptions can be avoided and the compiler will be able to catch such issues which in turn help a programmer to build a bug free code. So if we convert the above code to use generic then it would look like this:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  List&amp;lt;String&amp;gt; list = new ArrayList&amp;lt;String&amp;gt;();&lt;br /&gt;
  list.add(&amp;quot;name&amp;quot;);&lt;br /&gt;
  Integer num = list.get(0); //line 1 &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Here at line 1 the compiler throws an error because the compiler on seeing the declaration of ArrayList will be expecting the list to have just &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt; and thereby the return type of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; to be &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Implementing Generics:'''&lt;br /&gt;
Java provides a feature which helps one to implement your own generic types and this will help to build more sophisticated and runtime error free applications. Consider the below example:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
   interface List&amp;lt;N&amp;gt; {&lt;br /&gt;
                         void add(N i);&lt;br /&gt;
                         Iterator&amp;lt;N&amp;gt; iterator();&lt;br /&gt;
                      }&lt;br /&gt;
   interface Iterator&amp;lt;N&amp;gt; {&lt;br /&gt;
                            N next();&lt;br /&gt;
                            boolean hasNext();&lt;br /&gt;
                         }&lt;br /&gt;
   class LinkedList&amp;lt;N&amp;gt; implements List&amp;lt;N&amp;gt; {&lt;br /&gt;
                          //Business Logic   &lt;br /&gt;
                 }&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
So here, &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt; can be replaced with any primitive data types or wrapper classes in the business logic. But we need to make sure that placeholders to be replaced with valid subtypes of Object. Generics implementation is not restricted for classes or interfaces, we can have for static/non static methods and constructors.&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
1. http://en.wikipedia.org/wiki/Generics_in_Java&lt;br /&gt;
&lt;br /&gt;
2. http://www.oracle.com/technetwork/articles/javase/generics-136597.html&lt;/div&gt;</summary>
		<author><name>Jnvarava</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6c_sj&amp;diff=54892</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6c sj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6c_sj&amp;diff=54892"/>
		<updated>2011-11-13T22:17:07Z</updated>

		<summary type="html">&lt;p&gt;Jnvarava: /* What are Generics in Java? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==What are Generics in Java?==&lt;br /&gt;
Generics were added to Java programming language as a part of J2SE 5.0 release in 2004. They allow programmers to develop generic and compile safe applications which enables a type or method to operate on objects of various type. This feature is well utilized while implementing [http://en.wikipedia.org/wiki/Java_Collections Java Collections]. The reason why people went into generic programming can be well explained using the below example:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  List list = new ArrayList();&lt;br /&gt;
  list.add(&amp;quot;name&amp;quot;);&lt;br /&gt;
  Integer num = (Integer)list.get(0);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
In this example, we insert a &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt; into an &amp;lt;code&amp;gt;ArrayList&amp;lt;/code&amp;gt; and retrieve element by typecasting with Integer wrapper class. This throws a runtime exception because of Illegal class cast. But if we use generics, runtime exceptions can be avoided and the compiler will be able to catch such issues which in turn help a programmer to build a bug free code. So if we convert the above code to use generic then it would look like this:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  List&amp;lt;String&amp;gt; list = new ArrayList&amp;lt;String&amp;gt;();&lt;br /&gt;
  list.add(&amp;quot;name&amp;quot;);&lt;br /&gt;
  Integer num = list.get(0); //line 1 &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Here at line 1 the compiler throws an error because the compiler on seeing the declaration of ArrayList will be expecting the list to have just &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt; and thereby the return type of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; to be &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Implementing Generics:'''&lt;br /&gt;
Java provides a feature which helps one to implement your own generic types and this will help to build more sophisticated and runtime error free applications. Consider the below example:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
   interface List&amp;lt;N&amp;gt; {&lt;br /&gt;
                         void add(N i);&lt;br /&gt;
                         Iterator&amp;lt;N&amp;gt; iterator();&lt;br /&gt;
                      }&lt;br /&gt;
   interface Iterator&amp;lt;N&amp;gt; {&lt;br /&gt;
                            N next();&lt;br /&gt;
                            boolean hasNext();&lt;br /&gt;
                         }&lt;br /&gt;
   class LinkedList&amp;lt;N&amp;gt; implements List&amp;lt;N&amp;gt; {&lt;br /&gt;
                          //Business Logic   &lt;br /&gt;
                 }&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
So here, &amp;lt;code&amp;gt;N&amp;lt;/code&amp;gt; can be replaced with any primitive data types or wrapper classes in the business logic. But we need to make sure that placeholders to be replaced with valid subtypes of Object.&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
1. http://en.wikipedia.org/wiki/Generics_in_Java&lt;br /&gt;
&lt;br /&gt;
2. http://www.oracle.com/technetwork/articles/javase/generics-136597.html&lt;/div&gt;</summary>
		<author><name>Jnvarava</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6c_sj&amp;diff=54891</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6c sj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6c_sj&amp;diff=54891"/>
		<updated>2011-11-13T22:04:46Z</updated>

		<summary type="html">&lt;p&gt;Jnvarava: /* What are Generics in Java? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==What are Generics in Java?==&lt;br /&gt;
Generics were added to Java programming language as a part of J2SE 5.0 release in 2004. They allow programmers to develop generic and compile safe applications which enables a type or method to operate on objects of various type. This feature is well utilized while implementing [http://en.wikipedia.org/wiki/Java_Collections Java Collections]. The reason why people went into generic programming can be well explained using the below example:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  List list = new ArrayList();&lt;br /&gt;
  list.add(&amp;quot;name&amp;quot;);&lt;br /&gt;
  Integer num = (Integer)list.get(0);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
In this example, we insert a &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt; into an &amp;lt;code&amp;gt;ArrayList&amp;lt;/code&amp;gt; and retrieve element by typecasting with Integer wrapper class. This throws a runtime exception because of Illegal class cast. But if we use generics, runtime exceptions can be avoided and the compiler will be able to catch such issues which in turn help a programmer to build a bug free code. So if we convert the above code to use generic then it would look like this:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  List&amp;lt;String&amp;gt; list = new ArrayList&amp;lt;String&amp;gt;();&lt;br /&gt;
  list.add(&amp;quot;name&amp;quot;);&lt;br /&gt;
  Integer num = list.get(0); //line 1 &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Here at line 1 the compiler throws an error because the compiler on seeing the declaration of ArrayList will be expecting the list to have just &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt; and thereby the return type of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; to be &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Implementing Generics:'''&lt;br /&gt;
Java provides a feature which helps one to implement your own generic types and this will help to build more sophisticated and runtime error free applications. Consider the below example:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
   interface List&amp;lt;N&amp;gt; {&lt;br /&gt;
                         void add(N i);&lt;br /&gt;
                         Iterator&amp;lt;N&amp;gt; iterator();&lt;br /&gt;
                      }&lt;br /&gt;
&lt;br /&gt;
   interface Iterator&amp;lt;N&amp;gt; {&lt;br /&gt;
                            N next();&lt;br /&gt;
                            boolean hasNext();&lt;br /&gt;
                         }&lt;br /&gt;
&lt;br /&gt;
   class LinkedList&amp;lt;N&amp;gt; implements List&amp;lt;N&amp;gt; {&lt;br /&gt;
                          //Business Logic   &lt;br /&gt;
                 }&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
1. http://en.wikipedia.org/wiki/Generics_in_Java&lt;br /&gt;
&lt;br /&gt;
2. http://www.oracle.com/technetwork/articles/javase/generics-136597.html&lt;/div&gt;</summary>
		<author><name>Jnvarava</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6c_sj&amp;diff=54890</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6c sj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6c_sj&amp;diff=54890"/>
		<updated>2011-11-13T21:59:00Z</updated>

		<summary type="html">&lt;p&gt;Jnvarava: /* Reference */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==What are Generics in Java?==&lt;br /&gt;
Generics were added to Java programming language as a part of J2SE 5.0 release in 2004. They allow programmers to develop generic and compile safe applications which enables a type or method to operate on objects of various type. This feature is well utilized while implementing [http://en.wikipedia.org/wiki/Java_Collections Java Collections]. The reason why people went into generic programming can be well explained using the below example:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  List list = new ArrayList();&lt;br /&gt;
  list.add(&amp;quot;name&amp;quot;);&lt;br /&gt;
  Integer num = (Integer)list.get(0);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
In this example, we insert a &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt; into an &amp;lt;code&amp;gt;ArrayList&amp;lt;/code&amp;gt; and retrieve element by typecasting with Integer wrapper class. This throws a runtime exception because of Illegal class cast. But if we use generics, runtime exceptions can be avoided and the compiler will be able to catch such issues which in turn help a programmer to build a bug free code. So if we convert the above code to use generic then it would look like this:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  List&amp;lt;String&amp;gt; list = new ArrayList&amp;lt;String&amp;gt;();&lt;br /&gt;
  list.add(&amp;quot;name&amp;quot;);&lt;br /&gt;
  Integer num = list.get(0); //line 1 &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Here at line 1 the compiler throws an error because the compiler on seeing the declaration of ArrayList will be expecting the list to have just &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt; and thereby the return type of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; to be &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Implementing Generics:'''&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
1. http://en.wikipedia.org/wiki/Generics_in_Java&lt;br /&gt;
&lt;br /&gt;
2. http://www.oracle.com/technetwork/articles/javase/generics-136597.html&lt;/div&gt;</summary>
		<author><name>Jnvarava</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6c_sj&amp;diff=54889</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6c sj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6c_sj&amp;diff=54889"/>
		<updated>2011-11-13T21:58:47Z</updated>

		<summary type="html">&lt;p&gt;Jnvarava: /* Reference */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==What are Generics in Java?==&lt;br /&gt;
Generics were added to Java programming language as a part of J2SE 5.0 release in 2004. They allow programmers to develop generic and compile safe applications which enables a type or method to operate on objects of various type. This feature is well utilized while implementing [http://en.wikipedia.org/wiki/Java_Collections Java Collections]. The reason why people went into generic programming can be well explained using the below example:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  List list = new ArrayList();&lt;br /&gt;
  list.add(&amp;quot;name&amp;quot;);&lt;br /&gt;
  Integer num = (Integer)list.get(0);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
In this example, we insert a &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt; into an &amp;lt;code&amp;gt;ArrayList&amp;lt;/code&amp;gt; and retrieve element by typecasting with Integer wrapper class. This throws a runtime exception because of Illegal class cast. But if we use generics, runtime exceptions can be avoided and the compiler will be able to catch such issues which in turn help a programmer to build a bug free code. So if we convert the above code to use generic then it would look like this:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  List&amp;lt;String&amp;gt; list = new ArrayList&amp;lt;String&amp;gt;();&lt;br /&gt;
  list.add(&amp;quot;name&amp;quot;);&lt;br /&gt;
  Integer num = list.get(0); //line 1 &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Here at line 1 the compiler throws an error because the compiler on seeing the declaration of ArrayList will be expecting the list to have just &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt; and thereby the return type of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; to be &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Implementing Generics:'''&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
1. http://en.wikipedia.org/wiki/Generics_in_Java&lt;br /&gt;
2. http://www.oracle.com/technetwork/articles/javase/generics-136597.html&lt;/div&gt;</summary>
		<author><name>Jnvarava</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6c_sj&amp;diff=54888</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6c sj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6c_sj&amp;diff=54888"/>
		<updated>2011-11-13T21:58:36Z</updated>

		<summary type="html">&lt;p&gt;Jnvarava: /* What are Generics in Java? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==What are Generics in Java?==&lt;br /&gt;
Generics were added to Java programming language as a part of J2SE 5.0 release in 2004. They allow programmers to develop generic and compile safe applications which enables a type or method to operate on objects of various type. This feature is well utilized while implementing [http://en.wikipedia.org/wiki/Java_Collections Java Collections]. The reason why people went into generic programming can be well explained using the below example:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  List list = new ArrayList();&lt;br /&gt;
  list.add(&amp;quot;name&amp;quot;);&lt;br /&gt;
  Integer num = (Integer)list.get(0);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
In this example, we insert a &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt; into an &amp;lt;code&amp;gt;ArrayList&amp;lt;/code&amp;gt; and retrieve element by typecasting with Integer wrapper class. This throws a runtime exception because of Illegal class cast. But if we use generics, runtime exceptions can be avoided and the compiler will be able to catch such issues which in turn help a programmer to build a bug free code. So if we convert the above code to use generic then it would look like this:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  List&amp;lt;String&amp;gt; list = new ArrayList&amp;lt;String&amp;gt;();&lt;br /&gt;
  list.add(&amp;quot;name&amp;quot;);&lt;br /&gt;
  Integer num = list.get(0); //line 1 &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Here at line 1 the compiler throws an error because the compiler on seeing the declaration of ArrayList will be expecting the list to have just &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt; and thereby the return type of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; to be &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
'''Implementing Generics:'''&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
1. http://en.wikipedia.org/wiki/Generics_in_Java&lt;/div&gt;</summary>
		<author><name>Jnvarava</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6c_sj&amp;diff=54887</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6c sj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6c_sj&amp;diff=54887"/>
		<updated>2011-11-13T21:52:21Z</updated>

		<summary type="html">&lt;p&gt;Jnvarava: /* What are Generics in Java? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==What are Generics in Java?==&lt;br /&gt;
Generics were added to Java programming language as a part of J2SE 5.0 release in 2004. They allow programmers to develop generic and compile safe applications which enables a type or method to operate on objects of various type. This feature is well utilized while implementing [http://en.wikipedia.org/wiki/Java_Collections Java Collections]. The reason why people went into generic programming can be well explained using the below example:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  List list = new ArrayList();&lt;br /&gt;
  list.add(&amp;quot;name&amp;quot;);&lt;br /&gt;
  Integer num = (Integer)list.get(0);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
In this example, we insert a &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt; into an &amp;lt;code&amp;gt;ArrayList&amp;lt;/code&amp;gt; and retrieve element by typecasting with Integer wrapper class. This throws a runtime exception because of Illegal class cast. But if we use generics, runtime exceptions can be avoided and the compiler will be able to catch such issues which in turn help a programmer to build a bug free code. So if we convert the above code to use generic then it would look like this:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  List&amp;lt;String&amp;gt; list = new ArrayList&amp;lt;String&amp;gt;();&lt;br /&gt;
  list.add(&amp;quot;name&amp;quot;);&lt;br /&gt;
  Integer num = list.get(0); //line 1 &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Here at line 1 the compiler throws an error because the compiler on seeing the declaration of ArrayList will be expecting the list to have just &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt; and thereby the return type of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; to be &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
1. http://en.wikipedia.org/wiki/Generics_in_Java&lt;/div&gt;</summary>
		<author><name>Jnvarava</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6c_sj&amp;diff=54886</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6c sj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6c_sj&amp;diff=54886"/>
		<updated>2011-11-13T21:51:54Z</updated>

		<summary type="html">&lt;p&gt;Jnvarava: /* What are Generics in Java? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==What are Generics in Java?==&lt;br /&gt;
Generics were added to Java programming language as a part of J2SE 5.0 release in 2004. They allow programmers to develop generic and compile safe applications which enables a type or method to operate on objects of various type. This feature is well utilized while implementing [http://en.wikipedia.org/wiki/Java_Collections Java Collections]. The reason why people went into generic programming can be well explained using the below example:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  List list = new ArrayList();&lt;br /&gt;
  list.add(&amp;quot;name&amp;quot;);&lt;br /&gt;
  Integer num = (Integer)list.get(0);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
In this example, we insert a &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt; into an &amp;lt;code&amp;gt;ArrayList&amp;lt;/code&amp;gt; and retrieve element by typecasting with Integer wrapper class. This throws a runtime exception because of Illegal class cast. But if we use generics, runtime exceptions can be avoided and the compiler will be able to catch such issues which in turn help a programmer to build a bug free code. So if we convert the above code to use generic then it would look like this:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  List&amp;lt;String&amp;gt; list = new ArrayList&amp;lt;String&amp;gt;();&lt;br /&gt;
  list.add(&amp;quot;name&amp;quot;);&lt;br /&gt;
  Integer num = list.get(0); //line 1 &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Here at line 1 the compiler throws an error because the compiler on seeing the declaration of ArrayList will be expecting the list to have just &amp;lt;code&amp;gt;String&amp;lt;/String&amp;gt; and thereby the return type of &amp;lt;code&amp;gt;get&amp;lt;/code&amp;gt; to be &amp;lt;code&amp;gt;String&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
1. http://en.wikipedia.org/wiki/Generics_in_Java&lt;/div&gt;</summary>
		<author><name>Jnvarava</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6c_sj&amp;diff=54884</id>
		<title>CSC/ECE 517 Fall 2011/ch6 6c sj</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011/ch6_6c_sj&amp;diff=54884"/>
		<updated>2011-11-13T20:10:21Z</updated>

		<summary type="html">&lt;p&gt;Jnvarava: Created page with &amp;quot;==What are Generics in Java?== Generics were added to Java programming language as a part of J2SE 5.0 release in 2004.     ==Reference== 1. http://en.wikipedia.org/wiki/Generics_...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==What are Generics in Java?==&lt;br /&gt;
Generics were added to Java programming language as a part of J2SE 5.0 release in 2004.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Reference==&lt;br /&gt;
1. http://en.wikipedia.org/wiki/Generics_in_Java&lt;/div&gt;</summary>
		<author><name>Jnvarava</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011&amp;diff=54875</id>
		<title>CSC/ECE 517 Fall 2011</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2011&amp;diff=54875"/>
		<updated>2011-11-13T19:39:46Z</updated>

		<summary type="html">&lt;p&gt;Jnvarava: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Link title]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1a ms]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1a cs]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1a ri]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1a lj]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1b sa]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1b ds]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1b tj]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1c cm]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1c sj]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1c ka]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1d sr]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1e vs]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1e aa]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1a sc]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1e dm]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1e an]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1e sa]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1e lm]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1g vn]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1f rs]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1f sv]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1g jn]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1h ps]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1e sm]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1i zf]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1g rn]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1i cl]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1d ss]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1i lj]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1h hs]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 1d gs]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 2b ns]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 2b jp]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 2a av]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch2 2f jm]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch2 2e ad]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch2 2e kt]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch2 2e gp]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 2b qu]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch2 2c bs]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 2c rs]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 2a ca]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch1 2b rv]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch2 2c ds]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch2 2b sa]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch2 2f mm]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch2 2f vh]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch2 2e ps]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch3 3a oe]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch3 3h rr]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch3 3h ss]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch3 4b js]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch3 4b ms]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4b ds]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4i aa]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4i sd]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4d mt]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4d ls]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4d ch]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4c ap]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4h sv]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4e cl]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4e gs]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4a ga]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4f sl]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4i js]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4f ss]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4c dm]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4g as]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4g nv]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4g ms]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4h kp]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4h as]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4j fw]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4f rs]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch4 4i lc]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch17 5b uo]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch17 5b br]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch5 5d he]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch5 6d ny]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch6 6d sk]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch6 6e ch]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch6 6b ra]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2011/ch6 6c sj]]&lt;br /&gt;
&lt;br /&gt;
*[[trial]]&lt;/div&gt;</summary>
		<author><name>Jnvarava</name></author>
	</entry>
</feed>