我试图插入这个简单的scala代码,但我遇到了一些麻烦.
package indicators
class DoubleRingBuffer(val capacity:Int=1000) {
var elements = new Array[Double](capacity);
private var head=capacity-1
private var max=0
def size ():Int = {
return max+1
}
def add(obj:Double):Double = {
head-=1
if (head<0) head=capacity-1
return set(max+1,obj)
}
def set(i:Int,obj:Double):Double = {
System.out.println("HI")
if (i>=capacity || i<0)
throw new IndexOutOfBoundsException(i+" out of bounds")
if (i>=max) max=i
var index = (head+i)%capacity
var prev = elements(index)
elements(index)=obj
return prev
}
def get(i:Int=0):Double = {
System.out.println("size is "+size())
if (i>=size() || i<0)
throw new …Run Code Online (Sandbox Code Playgroud) 我想自定义matplotlib图像显示,以便我可以键入control-c,它会将图像复制到剪贴板,然后我可以将其复制到openoffice电子表格来组织我的所有原始数据和图像结果.有没有办法做到这一点?谢谢!