diff --git a/SWIG/Doc/Devel/internals.html b/SWIG/Doc/Devel/internals.html index 4a8988bb5..4fd2d53ba 100644 --- a/SWIG/Doc/Devel/internals.html +++ b/SWIG/Doc/Devel/internals.html @@ -423,13 +423,112 @@ operations that allow them to be used interchangeably with DOH file objects.
+Example usage of lists: +
+ +
+
+/* Create and populate */
+List *list = NewList();
+Append(list, NewString("listval1"));
+Append(list, NewString("listval2"));
+Append(list, NewString("listval3"));
+Append(list, NewString("listval4"));
+Append(list, NewString("listval5"));
+
+/* Size */
+Printf(stdout, "list len: %d\n", Len(list));
+
+/* Delete */
+Delitem(list, 3);
+
+/* Replace */
+Setitem(list, 0, NewString("newlistval1"));
+
+/* Get */
+String *item = Getitem(list,1);
+if (item)
+ Printf(stdout, "get: %s\n", item);
+else
+ Printf(stdout, "get: [non-existent]\n");
+
+/* Iterate through the container */
+int len = Len(list);
+for (int i=0; i<len; i++) {
+ String *item = Getitem(list,i);
+ Printf(stdout, "list item: %s\n", item);
+}
+
+
+
++Resulting output: +
+ +++hash len: 5 +get: hashval2 +hash item: hashval5 [h5] +hash item: hashval1 [h1] +hash item: hashval2 [h2] +hash item: hashval3 [h3] ++
+Example usage of hash tables: +
+ +
+
+/* Create and populate */
+Hash *hash = NewHash();
+Setattr(hash, "h1", NewString("hashval1"));
+Setattr(hash, "h2", NewString("hashval2"));
+Setattr(hash, "h3", NewString("hashval3"));
+Setattr(hash, "h4", NewString("hashval4"));
+Setattr(hash, "h5", NewString("hashval5"));
+
+/* Size */
+Printf(stdout, "hash len: %d\n", Len(hash));
+
+/* Delete */
+Delattr(hash, "h4");
+
+/* Get */
+String *item = Getattr(hash, "h2");
+if (item)
+ Printf(stdout, "get: %s\n", item);
+else
+ Printf(stdout, "get: [non-existent]\n");
+
+/* Iterate through the container */
+Iterator it;
+for (it = First(hash); it.key; it= Next(it))
+ Printf(stdout, "hash item: %s [%s]\n", (it.item), (it.key));
+
+
+
++Resulting output: +
+ +++list len: 5 +get: listval2 +list item: newlistval1 +list item: listval2 +list item: listval3 +list item: listval5 ++
The representation and manipulation of types is currently in the process of being reorganized and (hopefully) simplified. The