Last active
August 29, 2015 14:05
-
-
Save Kalinovych/97c9068f316d9125a040 to your computer and use it in GitHub Desktop.
LinkedList Velocity Template for Intellij Idea
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#parse("ActionScript File Header.as") | |
#set($T='*') | |
#if(${GenericClass} && ${GenericClass} != "")#set($T=${GenericClass})#end | |
#set( $NodeType = 'LLItemNode' ) | |
#if ( ${T} != "") #set( $NodeType = "${T}Node" ) #end | |
## force capitalize first char | |
#set( $NodeType = "$NodeType.toString().substring(0,1).toUpperCase()$NodeType.toString().substring(1)" ) | |
package ${PACKAGE_NAME}#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "") #end{ | |
import flashrush.ds.collections.LinkedListBase; | |
import flashrush.ds.collections.list_internal; | |
${Access_modifier} final class ${NAME} extends LinkedListBase { | |
public function ${NAME}() { | |
super(); | |
} | |
[Inline] | |
public final function get firstNode():${NodeType} { | |
return _firstNode; | |
} | |
[Inline] | |
public final function get lastNode():${NodeType} { | |
return _lastNode; | |
} | |
[Inline] | |
public final function get length():uint { | |
return _length; | |
} | |
public function push(item:${T} ):void { | |
const node:${NodeType} = _createNode(item); | |
\$attach(node); | |
} | |
public function pop():${T} { | |
if (_length == 0) return null; | |
const node:${NodeType} = \$detachLast(); | |
const item:${T} = node._item; | |
_disposeNode(node,true); | |
return item; | |
} | |
public function unshift(item:${T} ):void { | |
const node:${NodeType} = _createNode(item); | |
\$attachFirst(node); | |
} | |
public function shift():${T} { | |
if (_length == 0) return null; | |
const node:${NodeType} = \$detachFirst(); | |
const item:${T} = node._item; | |
_disposeNode(node,true); | |
return item; | |
} | |
[Inline] | |
protected final function _createNode( item:* ):${NodeType} { | |
return new ${NodeType}( item ); | |
} | |
[Inline] | |
protected final function _disposeNode( node:${NodeType}, disposeLinks:Boolean ):void { | |
if (disposeLinks) { | |
node.list_internal::prev = null; | |
node.list_internal::next = null; | |
} | |
node._item = null; | |
} | |
} | |
} | |
import flashrush.ds.collections.LLNodeBase; | |
import flashrush.ds.collections.list_internal; | |
internal final class ${NodeType} extends LLNodeBase { | |
internal var _item:${T}; | |
public function ${NodeType}(item:${T}) { | |
_item = item; | |
} | |
[Inline] | |
public final function get item():${T} { | |
return _item; | |
} | |
[Inline] | |
public final function get prevNode():${NodeType} { | |
return list_internal::prev; | |
} | |
[Inline] | |
public final function get nextNode():${NodeType} { | |
return list_internal::next; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment