[Nice-commit] Nice/stdlib/nice/lang array.nice,1.21,1.22 graph.nice,1.15,1.16 prelude.nice,1.26,1.27
Brought to you by:
bonniot
|
From: <ar...@us...> - 2003-03-27 23:01:10
|
Update of /cvsroot/nice/Nice/stdlib/nice/lang
In directory sc8-pr-cvs1:/tmp/cvs-serv23760/F:/nice/stdlib/nice/lang
Modified Files:
array.nice graph.nice prelude.nice
Log Message:
Added elementNotNull and use an assertion for the check.
Index: array.nice
===================================================================
RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/array.nice,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** array.nice 12 Feb 2003 13:37:58 -0000 1.21
--- array.nice 27 Mar 2003 23:01:00 -0000 1.22
***************
*** 24,27 ****
--- 24,34 ----
= native;
+ <Any T> !T[] elementsNotNull(?T[] arr)
+ {
+ assert(!arr.has(?T elem => elem == null));
+ return cast(arr);
+ }
+
+
/** Returns an array with the newSize first elements.
The result can be the same array as the argument.
Index: graph.nice
===================================================================
RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/graph.nice,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** graph.nice 24 Jan 2003 12:36:47 -0000 1.15
--- graph.nice 27 Mar 2003 23:01:02 -0000 1.16
***************
*** 34,44 ****
successors(node).foreach(T child=>{
int m;
! try{
! m = notNull(mark.get(child));
! }
! catch(NullPointerException e){
m = visit(child, successors, id, stack, mark, res);
! }
!
if(m<min)
min=m;
--- 34,42 ----
successors(node).foreach(T child=>{
int m;
! if (mark.get(child)==null)// optionOr crashes the compiler here so we fake
m = visit(child, successors, id, stack, mark, res);
! else
! m = cast(mark.get(child));
!
if(m<min)
min=m;
Index: prelude.nice
===================================================================
RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/prelude.nice,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** prelude.nice 23 Mar 2003 00:05:48 -0000 1.26
--- prelude.nice 27 Mar 2003 23:01:02 -0000 1.27
***************
*** 45,54 ****
<Any T> !T notNull(?T value)
{
! if (value != null)
! return cast(value);
!
! if (true)
! throw new NullPointerException("Null value");
! return cast(null);
}
--- 45,50 ----
<Any T> !T notNull(?T value)
{
! assert(value != null);
! return cast(value);
}
|