所以我有这个堆栈,我不知道如何将它的内容复制到队列然后反之亦然(当从队列复制回堆栈时,值会向后倒?)
Stack st = new Stack();
st.Push('E');
st.Push('L');
st.Push('P');
st.Push('M');
st.Push('A');
st.Push('X');
st.Push('E');
答案 0 :(得分:3)
Stack
实施ICollection
,因此您可以Queue
ICollection
Queue queue = new Queue(st);
使用Stack st2 = new Stack(queue);
:
start = function () {
this.data("ox", +this.getBBox().cx);
this.data("oy", +this.getBBox().cy);
},
move = function (dx, dy) {
var tmpPt = {
x: this.data('ox') + dx,
y: this.data('oy') + dy
};
// move will be called with dx and dy
l = gradSearch(l, tmpPt);
pt = path.getPointAtLength(l);
if (!isNaN(pt.x) && !isNaN(pt.y)) {
this.transform('t' + (pt.x - this.data("ox")) + ',' + (pt.y - this.data("oy")));
};
},
end = function () {
console.log('End of drag');
}
同样适用于Stack:
import numpy as np
import scipy as sc
import matplotlib.pyplot as plt
x = np.linspace (0, 10, 100)
y = .5 * x + 4
plt.figure ()
yres = 100
ymax = np.max (y)
ymin = 0
yy = np.linspace (ymin, ymax, yres)
fill_n = 10
xres = len(x)
# gradient image
gI = np.zeros ((yres, xres))
for xi,xx in enumerate(x):
ym = y[xi]
# find elment closest to curve
ya = np.argmin (np.abs(yy - ym))
gI[ya-fill_n:ya, xi] = np.linspace (0, 1, fill_n)
# make alpha cmap out of gray map
bb = np.linspace (0, 1, fill_n)
kk = []
for b in bb:
kk.append ((b, b, b))
bb = tuple (kk)
gr = { 'blue' : bb,
'red' : bb,
'green': bb,
'alpha': bb }
plt.register_cmap (name = 'GrayAlpha', data = gr)
gI = np.flipud (gI)
plt.imshow (gI, vmin = 0, vmax = 1, cmap = 'GrayAlpha', interpolation = 'bicubic')
plt.show ()