scala - Scala 编辑擦除
问题描述
我有一系列需要通过的测试,其中一个是编辑擦除。
/**
* Edit Erase (forward delete). Delete the character to the right of the
* cursor. If the cursor is at the end of the buffer then ignore this command
* (there is no character to the right of the cursor). If deletion succeeds
* then do not change the cursor position. The marker position is not
* changed UNLESS the deletion has caused it to point beyond the end of the
* (updated) buffer. In this case make the marker equal to end.
*/
Marker 和 Cursor 是 Int 并且缓冲区是一个字符串。
我需要做的是,如果光标是结尾(buffer.length),则需要忽略该命令,但是我坚持的位是仅在删除导致标记时才使标记移动到结尾大于缓冲区长度。
我已经写了一些代码,但是对此有什么建议吗?
def ee() {
if(cursor != end) {
buffer.delete(cursor,cursor+ 1)
if(marker > end)
marker = buffer.length
}
}
解决方案
推荐阅读
- powershell - 如果不在 AD 组中,有关删除 AD 组的 if/else 循环语法的建议
- c - 将文件写入缓冲区
- r - taskscheduler_create() 多天 - 每月 - R
- c++ - 为什么非专业模板胜过部分专业模板?
- javascript - Uncaught TypeError: Object(...) is not a function at handleChange
- julia - 数据框在excel文件中的空行之前被剪切
- git - 您的分支和 'origin/integration/phone_number_change' 已经分道扬镳
- encryption - TLS 1.2 密码套件错误,Schannel 事件 ID 36874 和 36888
- excel - Excel。1 个特定列的特殊数字分隔符格式,整个文档没有
- r - R rowSums() 正在生成一个奇怪的输出。我究竟做错了什么?