File: aslist.Rd

package info (click to toggle)
rjava 1.0-14-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,188 kB
  • sloc: java: 13,223; ansic: 5,503; sh: 3,776; xml: 325; makefile: 250; perl: 33
file content (59 lines) | stat: -rw-r--r-- 1,463 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
\name{aslist}
\alias{as.list.jobjRef}
\alias{as.list.jarrayRef}
\alias{as.list.jrectRef}
\title{
Converts java objects or arrays to R lists
}
\description{
	\code{as.list} is implemented for java objects and java arrays
	to facilitate using \code{lapply} calls over elements of a java array
	or items of an Iterator associated with an Iterable object
	
	For java array references, \code{as.list} is mapped to
	\code{\link{.jevalArray}}
	
	For java objects that implement the Iterable interface, 
	the list is created by iterating over the associated iterator
}
\usage{
\S3method{as.list}{jobjRef}(x, ...)
\S3method{as.list}{jarrayRef}(x, ...)
}
\arguments{
  \item{x}{java array or Iterable java object}
  \item{\dots}{ignored}
}
\value{
An R list, or vector.
}
\note{
The function is not intended to be called directly. It is implemented
so that java arrays or Iterable java objects can be used as the first 
argument of \code{\link{lapply}}
}
\seealso{
	\code{\link{.jevalArray}}, \code{\link{lapply}}
}
\examples{
\dontshow{.jinit()}
  # lapplying over a java array
  a <- .jarray( list( 
	.jnew( "java/awt/Point", 10L, 10L ), 
	.jnew( "java/awt/Point", 30L, 30L )
  ) )
  lapply( a, function(point){ 
	with(point, { 
		(x + y ) ^ 2
	} )
  } )

# lapply over a Vector (implements Iterable)
v <- .jnew("java/util/Vector")
v$add( "foo" )
v$add( .jnew("java/lang/Double", 10.2 ) )
sapply( v, function(item) item$getClass()$getName() )

}
\keyword{ programming }