Qunee for HTML5 - English : Element Management

Element management is the basic function of graph model. The graph model has functions of Array and Map. The internal manages the elements via array and ID mapping table. Adding and removal of elements, sequence modification and acquire traversal operation 

Adds or remove

  •  #add(data, index) - Adds elements
  • #clear() - Clear elements
  • #remove(data)
  • #removeById(id)
  • #set(data)

Other collection operation function

  • #contains(data) - whether containing elements
  • #containsById(id) - whether containing elements of appointed id
  • #get(index) - acquire elements by array position
  • #getById(id) - acquire elements by ID

#indexOf(data) - acquire array position of elements

#setIndex(data, index) - set the array position of elements

#size() - collection size

#length - collection size

#forEach(call, scope, params) - traverse according to array collection

#forEachReverse(call, scope, params) - traverse reversely by array collection


Adds elements in graph model, and traverse the model reversely 

var model = new Q.GraphModel();
model.add(new Q.Node('A'));
model.add(new Q.Node('B'));
model.add(new Q.Node('C'));
Q.log('model size: ' + model.length);
Q.log('the first node is: ' + model.get(0).name);

Print results 

model size: 3